A design pattern in .NET is a reusable, named solution to a recurring software design problem, expressed as a set of collaborating classes or objects; it is not a .NET language feature, a NuGet package, or a framework API, although .NET's own libraries and conventions are shaped by many classic patterns and the platform supplies idioms (interfaces, delegates, generics, events, IDisposable, dependency injection) that make certain patterns easier to implement than in older languages. The phrase "design pattern in .NET" is ambiguous in one important way: it can mean (a) the general object-oriented pattern catalog popularized by the "Gang of Four" (GoF) and applied in C#/.NET code, or (b) patterns specific to .NET's own ecosystem and conventions—sometimes called .NET idioms or framework patterns. Both readings are legitimate; this answer covers the first in depth and marks where the second differs.
What Counts as a Design Pattern
A design pattern has four recognizable parts: a name (so developers can discuss it in one word), a problem context (when it applies), a solution structure (roles, responsibilities, collaborations), and consequences (trade-offs). The name matters more than it looks. Saying "wrap the third-party client behind our own interface so tests can substitute it" and saying "use Adapter" convey the same design, but the second compresses a paragraph into two words.
A pattern is not the same as an algorithm. An algorithm is a procedure with a definite sequence of steps—quicksort, binary search, Dijkstra's algorithm. A pattern describes how objects relate and divide responsibility; the actual steps are supplied by the application. Nor is a pattern the same as a data structure: a Dictionary<TKey,TValue> is a concrete container, while the pattern question is who owns it, who mutates it, and how callers see it.
There is also a useful distinction between a pattern and a language idiom. An idiom is a pattern so tightly bound to one language that it rarely travels. In C#, the using statement plus IDisposable is an idiom for deterministic resource cleanup; yield return is an idiom for lazy sequence generation. Both are .NET-specific and would be described differently in Java or Python. Patterns in the GoF sense are meant to be language-agnostic, though their implementation naturally bends to C#'s features.
The Classic Catalog, Grouped
The most cited catalog is from Design Patterns: Elements of Reusable Object-Oriented Software (1994) by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides—the "Gang of Four." It lists 23 patterns in three groups. The grouping is didactic, not sacred; some patterns sit near boundaries.
Creational patterns concern how objects get made, so that code depends on interfaces rather than concrete constructors.
Abstract Factory supplies an interface for creating a family of related objects without naming concrete classes. In .NET, DbProviderFactory is the textbook example: the same code creates connections and commands for SQL Server, SQLite, or another provider because it works against the abstract factory. Builder separates construction of a complex object from its representation, usually through a fluent chain. StringBuilder is a loose example (it builds a string incrementally), while IHostBuilder in the generic host is a stronger one: configuration, services, and logging are layered on step by step before Build() produces the host. Factory Method lets a class defer instantiation to subclasses. The CreateConnection() method on an abstract provider is a factory method. Prototype creates new objects by cloning an existing instance. C# supports this with ICloneable and MemberwiseClone, though ICloneable is widely criticized because it does not say whether the clone is shallow or deep—a genuine ambiguity that has led many teams to define their own DeepClone methods instead. Singleton ensures one instance with a global access point. In .NET the cleanest modern form is often a statically initialized Lazy or a DI container registration with singleton lifetime, rather than a hand-written Instance property.
Structural patterns concern how classes and objects are composed.
Adapter converts one interface into another that clients expect. Wrapping a third-party payment SDK behind your own IPaymentGateway is an adapter, and it earns its keep in testing because the interface can be faked. Bridge separates an abstraction from its implementation so both can vary independently. A report type (summary vs. detailed) combined with an export format (PDF vs. CSV) is a classic two-dimension example; inheritance would multiply subclasses, while a bridge composes two hierarchies. Composite treats individual objects and groups uniformly, usually through a common interface. A file-system tree where File and Directory both implement IFileSystemNode is the standard illustration. Decorator adds behavior by wrapping an object that implements the same interface. Stream in .NET is the canonical case: new GZipStream(new BufferedStream(fileStream), CompressionMode.Decompress) stacks responsibilities without subclassing each combination. Facade provides a simplified interface over a subsystem. A CheckoutService that coordinates inventory, payment, and email behind one method is a facade—not the same as Adapter, which changes an interface to match an expected one rather than merely simplifying. Flyweight shares fine-grained objects to reduce memory. String interning and cached immutable value objects are the usual .NET-adjacent examples. Proxy stands in for another object to control access. A lazily loaded entity in an ORM, or a remoting/WCF-style transparent proxy, fits; so does a caching proxy that returns a stored result before hitting the real service.
Behavioral patterns concern communication and responsibility among objects.
Chain of Responsibility passes a request along a chain until a handler deals with it. ASP.NET Core middleware is the best-known .NET instance: each middleware component can handle the request, short-circuit, or call next. Command encapsulates a request as an object. Undo stacks, queued jobs, and ICommand in UI frameworks (WPF, MAUI) are common forms, though ICommand is a narrower UI contract than the full pattern. Interpreter represents a grammar as a class hierarchy and evaluates it. It is rare in line-of-business .NET code and appears mostly in small expression evaluators. Iterator provides sequential access without exposing underlying representation. IEnumerable and IEnumerator are the platform's built-in iterator contract, and yield return makes writing one trivial. Mediator centralizes communication between objects. MediatR-style in-process messaging is a popular .NET implementation, though it is often used more as a request dispatcher than as a true colleague-coordinating mediator. Memento captures and restores an object's state without breaking encapsulation. Undo/redo in editors is the typical case. Observer defines a one-to-many dependency so subscribers are notified of changes. C# events and IObservable/IObserver are the native mechanisms; the pattern's dangers—unsubscribed handlers leaking memory—are also native. State lets an object alter behavior when its internal state changes, often by delegating to state objects. An order lifecycle (New → Paid → Shipped → Closed) with per-state allowed transitions is a clean fit. Strategy defines a family of interchangeable algorithms behind a common interface. Passing an IComparer to List.Sort is strategy in miniature; a pricing engine that swaps discount rules at runtime is a fuller example. Template Method puts an algorithm's skeleton in a base class and lets subclasses override specific steps. Stream's pattern of a public Read that calls an abstract ReadCore-style method in derived streams reflects this idea, as do many BackgroundService implementations that override ExecuteAsync. Visitor adds operations to an object structure without modifying its classes, typically via a double-dispatch Accept(IVisitor) method. It is powerful but rigid: adding a new element type means updating every visitor.
How .NET Changes the Picture
C# and .NET shift the cost of several patterns, which is why blind pattern application is a common junior mistake.
Delegates and lambdas reduce the need for one-method interfaces. Strategy, Command, and Observer can often be expressed as a Func, Action, or event handler instead of a class hierarchy. A Func<Order, decimal> discount calculator is a strategy with no IDiscountStrategy required. The interface still earns its place when the behavior needs a name, multiple methods, or DI registration, but the ceremony is optional.
Generics reduce casting and duplication. Factory and Repository implementations can be generic (IRepository), which removes many of the casts that made the 1994 Java examples verbose.
Dependency injection is built in. Microsoft.Extensions.DependencyInjection makes Singleton, Factory, and Decorator registrations routine; lifetime bugs (a singleton capturing a scoped service) become the practical concern rather than object construction itself.
Language features absorb some patterns. Iterators (yield return), IDisposable with using, and async/await are so idiomatic that developers use them without naming a pattern. That is fine—patterns are vocabulary for design decisions, not badges of diligence.
A Concrete Comparison: Adapter vs. Decorator vs. Facade
These three are frequently confused because all wrap something. The distinguishing question is why the wrapper exists.
| Pattern | Purpose | Interface relationship | Typical .NET sign |
|---|---|---|---|
| Adapter | Make an existing type fit an expected interface | Wrapper implements the target interface, holds the adaptee | Wrapping a vendor SDK behind your own interface |
| Decorator | Add behavior while preserving the interface | Wrapper implements the same interface as the wrapped object | Stream stacking (GZipStream, CryptoStream) |
| Facade | Simplify a complex subsystem | Wrapper exposes a new, smaller interface | A service method coordinating several subsystems |
An example makes it concrete. Suppose you must call a legacy SOAP billing service. An adapter exposes IBillingService.Charge(...) and translates to the SOAP call. If you then want to log every charge, a decorator implements IBillingService, logs, and delegates to the adapter. If checkout must also reserve inventory and send receipts, a facade (CheckoutService) coordinates billing, inventory, and notification. Each wrapper is justified by a different force; collapsing them into one class usually produces a class that is hard to test and harder to change.
Patterns Specific to the .NET Ecosystem
Beyond the GoF catalog, .NET practitioners use patterns that are partly platform conventions. These are worth naming because they are what many people actually mean by "design patterns in .NET."
Repository and Unit of Work. A repository mediates between the domain and data mapping layers; a unit of work tracks changes and commits them atomically. Entity Framework Core's DbContext is effectively a unit of work plus repositories (DbSet). Whether to wrap EF Core in additional repositories is a genuine, unresolved debate: some teams do it for testability and domain isolation, others consider it a leaky abstraction over an already abstracted ORM. Model-View-Controller, MVVM, and MVP. ASP.NET Core MVC and Razor Pages use MVC; WPF and .NET MAUI commonly use MVVM, where INotifyPropertyChanged and data binding carry the view-model communication. Options pattern. IOptions, IOptionsSnapshot, and IOptionsMonitor bind configuration sections to typed settings classes—a .NET-specific pattern for configuration. Middleware / pipeline pattern. ASP.NET Core's request pipeline is chain of responsibility with a strongly typed delegate (RequestDelegate) and explicit ordering. Hosted service / background worker pattern. BackgroundService and IHostedService structure long-running work with the generic host's lifetime. Ambient context. HttpContext and TransactionScope are ambient contexts—state implicitly available to callees. It is convenient and easy to abuse; hidden dependencies make testing and reasoning harder. Circuit breaker, retry, and bulkhead. These resilience patterns are implemented in .NET by libraries such as Polly (and, in newer .NET versions, by Microsoft.Extensions.Http.Resilience). They are architectural rather than object-design patterns, but they are asked about under the same heading.
Where Patterns Stop Applying
Patterns are not a checklist to maximize. Several failure modes recur.
Pattern overuse. Applying Abstract Factory, Strategy, and Visitor to a 300-line console utility adds indirection without reducing change cost. The honest test is: what variation does this pattern absorb, and is that variation actually expected? If there is exactly one implementation and no near-term plan for a second, the interface may still be worth it for testing, but the factory probably is not.
Patterns as a substitute for design. A class named OrderManagerFactorySingletonHelper is a warning sign, not a credential. Names should describe the role in the domain, not advertise the pattern.
Forcing Java-era shapes onto C#. An AbstractSingletonProxyFactoryBean-style stack makes sense in some frameworks; in modern .NET it usually means the design has not used DI and delegates where it could.
Confusing pattern with framework feature. Saying "ASP.NET Core uses the Repository pattern" is imprecise. ASP.NET Core is a web framework; EF Core's DbContext resembles a unit of work, and DbSet resembles a repository, but the framework does not enforce that terminology. Precision matters because it keeps discussions about trade-offs grounded.
How to Recognize the Right Pattern
A practical approach is to start from the axis of change rather than the catalog. Ask what is likely to vary: the algorithm (strategy), the object's construction (factory or builder), the interface expected by a caller (adapter), the behavior added around an object (decorator), the state-dependent behavior (state), the notification of interested parties (observer), or the sequence of handlers (chain of responsibility). Naming the axis usually identifies the pattern faster than scanning a list of 23.
Second, check the consequences. Decorator increases the number of small classes and can complicate debugging because behavior is spread across wrappers. Singleton introduces global state and complicates testing. Observer can leak subscribers. Visitor makes adding element types expensive. A pattern chosen with its costs acknowledged is a design decision; one chosen because it sounds advanced is decoration.
Third, prefer the simplest .NET mechanism that satisfies the requirement. A Func may replace a strategy interface; an event may replace an observer class; IOptions may replace a hand-rolled configuration singleton. Reach for the full pattern when the simpler mechanism stops communicating intent or stops supporting the required variation.
A Short Illustrative Example
Consider a document exporter that must produce PDF and CSV and must log each export. A naive design subclasses Exporter into PdfExporter and CsvExporter and puts logging in each, so adding a format or changing logging multiplies edits. A pattern-informed design separates the format (strategy: IExportFormat with PdfFormat and CsvFormat) from the cross-cutting logging (decorator: LoggingExporter wrapping any IExportFormat), and a small factory or DI registration selects the format from configuration. Adding a format means one new class; changing logging means one class. That is the payoff patterns are supposed to deliver: localized change, not extra ceremony.
Common Misconceptions, Briefly
"A pattern is a library." No. Libraries implement patterns; the pattern is a design vocabulary. "More patterns mean better architecture." No. Patterns are means; coupling, cohesion, and change cost are the ends. "Design patterns are obsolete in modern C#." Partly false. Some patterns are absorbed by language features, but the underlying design problems—varying algorithms, wrapping interfaces, managing state transitions—remain. "Singleton guarantees one instance per application." Only within one process and one class loader context; multiple processes, multiple app instances, and some container scenarios break the assumption. In distributed systems, a singleton object is not a distributed singleton. "Repository always improves testability." It can, but a repository that mirrors EF Core's API one-to-one often adds a layer without adding abstraction, and in-memory providers can behave differently from real databases.
FAQ
Is a design pattern the same as an architecture pattern? No. Architecture patterns (layered, hexagonal, microservices, CQRS) describe system-level structure; design patterns describe object-level collaboration. The two interact—hexagonal architecture, for instance, leans on adapters and ports—but they operate at different scales.
Do I need to memorize all 23 GoF patterns? No. Most .NET developers use a handful regularly—strategy, adapter, decorator, factory, observer, repository, unit of work, middleware—and recognize the rest. Memorization without the problem context is not useful.
Are design patterns language-specific? The GoF catalog is language-agnostic in intent, but implementations vary. C# delegates, generics, events, and DI change how much boilerplate a pattern needs.
Where can I see patterns in the .NET base class library? Stream and its decorators, IEnumerable/IEnumerator as iterator, DbProviderFactory as abstract factory, events as observer, and IHostBuilder as builder are stable examples. None of these are labeled as patterns in the API; the labels are interpretive.
Does using patterns make code "enterprise-grade"? No. Patterns address specific variation and coupling problems. Code that uses patterns without those problems is often harder to maintain than straightforward code.
The short version: in .NET, a design pattern is a named, reusable design solution applied through C# and .NET idioms—valuable when it localizes a real axis of change, harmful when it is applied as decoration. The classic GoF catalog supplies most of the vocabulary, while the .NET ecosystem adds conventions such as repository/unit of work, options, middleware, and hosted services that many teams discuss under the same heading.