StreamReader Class in C# with Example

StreamReader class is basically used for reading text files.  StreamReader class resides in System.IO namespace.  If you want to make use of StreamReader class, then you must include System.IO namespace by making use of using keyword on top of your code.  StreamReader class got various methods like ReadLine(), ReadToEnd(), etc. Upon creating an instance of

Multicast Delegate in C# with Example

Multicast delegate contains reference to more than one method or it could be a combination of other delegates, which is also known as delegate chaining.  In delegate chaining, whenever you invoke your multicast delegate, all the delegates in its chain will be invoked automatically.  Before adding any more delegates to the chain, you must make

Delegate in C# with Example

A delegate is a reference type.  To create a delegate, we make use of a delegate keyword. The syntax of a delegate is pretty much similar to the syntax of a method, but with a delegate keyword.  A delegate always holds reference to a method and whenever you invoke the delegate, that method will be

Multiple Class Inheritance Using Interfaces in C#

As you know, multiple class inheritance is not possible in C#.  But you can achieve this goal using interfaces because multiple interface inheritance is allowed in C#.  We can learn this thing better with an example. Create 2 interfaces IA and IB.  IA contains a method PrintA() and IB contains a method PrintB().  Create 3

What is Diamond Problem in C#?

I hope you have already came across questions such as why C# doesn’t support multiple inheritance, why multiple inheritance is not supported in C# etc.  One of the main reason behind this is Diamond Shape Problem.  You can learn better about this problem with an example.  Suppose you have 4 classes named as A, B, C,