- A class can be inherited from other existing classes where a structure can't be inherited.
- A class can have instance constructors with or without parameters where a structure can have instance constructor.
- A class can be declared as protected, but a structure can't be.
- 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.
- 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.
Difference between a class & a structure?
Subscribe to:
Post Comments
(
Atom
)
0 comments :
Post a Comment