Difference between a class & a structure?

  1. A class can be inherited from other existing classes where a structure can't be inherited.
  2. A class can have instance constructors with or without parameters where a structure can have instance constructor.
  3. A class can be declared as protected, but a structure can't be.
  4. A class is a reference type so it created at run time in heap memory where as a structure is a value type so it created at compile time in stack memory.
  5. Objects created by a class can be destroyed by using Garbage Collector because they use heap memory. Structures can't be destroyed by using Garbage Collector because they use stack memory.

0 comments :

Post a Comment

> Related Posts with Thumbnails
 

Copyright © 2012. GS dot net - All Rights Reserved - Design by BTDesigner - Proudly powered by Blogger