Posted on Tuesday September 2, 2008

C# Design Patterns



Download example solution

Featured above are 7 design patterns given with example source code along a brief summary and example code. The idea is to keep the summary and example brief, serving as an overview instead of an in-depth description of each. If you are after more detailed information on each pattern have a look at the links section at the end of the article, which includes books. These books along with the information online are where I’ve based my source code and descriptions from, and also from using them over the years -sometimes without realising its a known pattern and other times deliberately.

I haven’t included any UML class diagrams to try to keep the article concise. If you find UML explains the class/interface relationships better then the Gang of Four and O’Reilly C# books all contain these and are definitely worth investing in. Or you can read the codeproject articles. The patterns aren’t categorised either as you’ll see.

The code examples are generally just the pattern itself (i.e. the classes/interfaces involved in the pattern) and not the types in use. The download link above contains a full solution of all 7 patterns (in Visual Studio 2008 format) with usage, so it’s worth downloading this to get a clearer picture.

Discover the Design Patterns You’re Already Using in the .NET Framework

MSDN article about the design patterns you’ve been using in the .NET framework perhaps without knowing.

Ian Mariano’s articles on

A series on design patterns in C#, with UML diagrams and categorised like the gang of four book into creational, behavioural, structural patterns.


Scroll to the bottom of the page for a list of patterns. Features some clear and concise example source code, mostly in Java.

Design patterns : elements of reusable object-oriented software

The original “gang of four” book, has clear descriptions and UML class diagrams.

C# 3.0 Design patterns

Quite a decent book with UML diagrams of each pattern. A little bit patchy with code examples in places, and the code is far from the FX-cop standards.

Martin Fowler’s website

The author of Patterns of Enterprise Application Architecture, another patterns book geared at software for the “enterprise” (not star trek).