Difference between class and structure in C#

Fundamental differences between struct and class.


Class is a reference type and its object is created on the heap memory.

Class can inherit the another class.

Class can have the all types of constructor and destructor.

The member variable of class can be initialized directly.

Class object can not be created without using the new keyword.


Structure is a value type that is why its object is created on the stack memory.

Structure does not support the inheritance of struct,  but can inherit interface.

Structure can only have the parametrized constructor. it means a structure can’t have the non-parametrized constructor,default constructor and destructor also.

The member variable of structure can not be initialized directly.


Later we will dive deeper into the differences between reference and value types.

Share this post:Tweet about this on TwitterShare on Facebook0Share on LinkedIn0Share on Google+0Share on Reddit0Email this to someoneDigg this