C#

C# Generic Methods

In my previous post, I explained about Generics. C# also provides generic methods. We can create a method that defers the parameter data type until the method is called. These parameters are called type parameters, which means we can pass the actual data type later. Below is an example of …

C# Generic Methods Read More
C#

C# Generics

Generics are introduced in C# 2.0. It is the most powerful features of C#. In C# 1.0, when we design a class that use other types that is not known at defining the structure of the class, then type should be an object type. In the class, we have to …

C# Generics Read More
C#

C# ArrayList

C# ArrayList is a non-generic dynamic size collection class. ArrayList class exists in System.Collections namespace. ArrayList are dynamic means we can add any number of items without specifying the size of it. ArrayList vs Array ArrayList and Array looks same. But there are some major differences between them. Differences are: …

C# ArrayList Read More
C#

C# Hashtable

C# Hashtable class is a collection class where we can store data in the key/value pair. Hashtable is not type-safe. Hashtable is not generic and both key and value are based on object type. Hashtable is used to store unique keys data. If we try to assign value to already used key, …

C# Hashtable Read More

Visitor Design Pattern

Visitor design pattern allows you to add new behaviors to an existing object without changing the object structure. Visitor pattern separates the non-related behaviors from the object and put them into a separate object. Visitor pattern creates a separate object for each new functionality. This pattern supports both single responsibility and open/closed SOLID principles. By …

Visitor Design Pattern Read More

Flyweight Design Pattern

Flyweight design pattern supports sharing of objects. In project, sometimes we have similar kinds of objects. Each object have two types of data. Intrinsic: This data is unique in all objects. Extrinsic: This data is common in all objects. Flyweight pattern gives you a pattern to design these objects lightweight by sharing the …

Flyweight Design Pattern Read More

Strategy Design Pattern

Strategy design pattern provides a family of algorithms. Each algorithm implements a single interface and all the algorithms are interchangeable. Client use the interface of the algorithm and can change the algorithm at runtime. Strategy pattern provides loosely coupling between the client and the algorithms. Structure Participants IStrategy: Defines an algorithm …

Strategy Design Pattern Read More

Memento Design Pattern

Memento design pattern provides the ability to store and restore object’s internal state without breaking encapsulation. This pattern is useful when we have to support undo or redo operations over an object. In OOPS, every object has internal state. To support undo/redo operations, we must save the state to somewhere. But due to encapsulation, object …

Memento Design Pattern Read More