Friday 12 April 2013

what is difference between class and structure in .net

 The Main difference of Both is :

 Class : 
  1. It was a Reference Type.
  2. Supports all the features of OOP'S.
  3. Gets it's memory allocated on managed heap. Because of this garbage collector provides memory management.
  4. Not faster in access than structure.
  5. Require a new operator for object creation.
  6. Default constructor in this was optional.
  7. Supports both implemenation and interface inheritance.
Structure :
  1. It was a value type.
  2. Doesn't support all the features like inheritance.
  3. Gets it's memory allocated on stack. Because of this garbage collector can't manage the memory .
  4. Faster in access.
  5. Doesn't require a new operator for object creation which was only optional.
  6. Default constructor in this was mandatory.
  7. Supports only interface inheritance.

No comments:

Post a Comment