• Archives

    » 2010 » July
Jul
28

understanding ‘using’ block in C#

using block in C# comes very handly while dealing with disposable objects. Disposable objects are those objects that can explicitly release the resources they use when called to dispose. As we know .Net garbage collection is non-deterministic so you can’t predict when exactly the object will be garbage collected. Many times we need to make [...]

Jul
23

Decorator Pattern with C#

Decorator pattern achieves a single objective of dynamically adding responsibilities to any object. Consider a case of a pizza shop. In the pizza shop they will sale a few pizza varieties and have toppings that customers can order additionally on top of a pizza. Customer can order a pizza and add as many as toppings [...]

Jul
7

Sealed classes as Generic type-constraints

We make heavy use of generics in our projects. Generics are really great deal when it comes to run-time polymorphism. Recently, one of my colleague came up with an idea to use a sealed class as generic type constraint. He wrote a sample code that looks like this. public sealed class MySealedClass { public MySealedClass() [...]