Sunday, January 13, 2013

Difference between Struct and Class in C#?


Struct 


  • Struct is value type so it store into stack. 
  • Struct can not be inherit.
  • No need new keyword to create an instance of a struct. New keyrowd is used only to call the constructor.


Class 


  • Class is reference type so it store into heap. 
  • Class can be inherit.
  • New keyword must use to create an instance of a class

No comments:

Post a Comment