Thursday, 5 April 2012

Difference between struct and classes

Struct

Classes

1. The struct is value type 1. The class is reference type
2. It inherits from System.ValueType 2.It inherits from the System.Object Type
3. The struct value will be stored on the stack memory. 3.The class object is stored on the heap memory.
4. Cannot implement Inheritance 4.implement Inheritance
5.The struct can have only constructor. 5.The class can have the constructor and destructor.
6. The struct can't initialize at the time of declaration. 6. The class can have the initializes fields.

No comments:

Post a Comment