views:

232

answers:

7

Which design patterns are build-in supported by C# regardless framework version? I'm thinking of patterns such as Observer pattern that can be found in interface IObservable. ObservableCollection, INotifyPropertyChanged etc.

Please provide with the namespace of the pattern in your answers!

+4  A: 

Iterator is one (all collection classes and arrays can use the foreach statement for iteration).

Another is the observer pattern - pretty much this is what events are. In 4.0 the IObservable and ObservableCollection were added.

Oded
+19  A: 

Action (normally used as visitor pattern)

Discover the Design Patterns You're Already Using in the .NET Framework (MSDN Magazine) http://msdn.microsoft.com/en-us/magazine/cc188707.aspx

jgauffin
+1 Nice link...
Oded
+1 I agree with Oded, nice link!
Will Marcouiller
A: 

The delegation pattern (that's what the delegates and expresssions are for)

Adrian Grigore
A: 

Abstract Factory: System.Data.Common.DbProviderFactory

Ruben
A: 

The proxy pattern is used often.

Zor
+3  A: 

StringBuilder uses the builder design pattern..
And there is the DbDataAdapter class (adapter pattern).
The Null Object pattern is broadly used as well.

Oren A
+1  A: 

Observer pattern. All our events and delegates are raised through the observer pattern.

Factory pattern. Connection strings and db providers from factory.

Iterator Pattern: Ienumerable, Ienumerators in our foreach statements

Adapter: COM communication. Runtime Callable Wrappers(RCW)

Template: Used in several places esp in ASP.NET classes where you can override to provide new implementation

Proxy: For all our webservice calls. in c# 3.0 we got proxy collections as well.

There could be many more. But these are the ones that came to my mind

Edwin