interviews.dotnetthread.com

↑ Grab this Headline Animator

Tuesday, August 5, 2008

Difference between classes and structures ?

A struct is a value type and a class is a reference type.
When we instantiate a class, memory will be allocated on the heap and for struct gets initiated, it gets memory on the stack.

Classes can have explicit parameter less constructors. But structs dosn't have this.
Classes support inheritance.
No inheritance for structs

A struct cannot inherit from another struct or class, and it cannot be the base of a class. Like classes, structures can implement interfaces.

Submit this story to DotNetKicks

No comments:

Post a Comment

Post your comments/questions/feedback for this Article.

 

Latest Articles