Category: C#

Difference Between Structure and Class in C#

We have seen how a class and a structure work.  They are pretty much similar in their functionality, but there are also certain differences between them.  The 5 important differences are given below. A structure is of value type and a class is of reference type. A class can have a destructor, but a structure

Difference Between Value Type & Reference Type in C#

We already know that int, double, float, struct etc are value type and classes, interface, delegates etc are reference type.  Now, this is the time to elaborate them a bit more, so that you can understand what actual happens behind the scenes. Value Type:  Value types are always stored in the stack.  They hold their

Structure in C# with Example

In C#, structure is very useful if you want to store some custom data.  Like a Class in C#, a structure can also have fields, methods, properties, and constructors.  Structure is pretty much similar to a class, but there are some differences between a structure and a class.  Structure is of value type and class

Properties in C# with Example

Before we start digging into properties, you need to know why we need properties.  Properties and access modifiers help in encapsulation.  Encapsulation in simple terms inclusion of one thing into another, so that the included thing should not be directly accessible or visible.  Encapsulation is one of the primary pillars of object oriented programming.  We

Method Overloading in C# with Example

We know very well how to create methods in C#.  We basically create methods to increase the code reusability.  Suppose if you want to add 2 numbers, you can create a method by the name of add_number with 2 parameters of type integer.  Same goes in case of adding or concatenating 2 strings, you can