What is the difference between Class and structures

Q

What is the difference between Class and structures ?

✍: Guest

A

Following are the key differences between them :-
? Structure are value types and classes are reference types. So structures use stack and classes use heap.
? Structures members can not be declared as protected, but class members can be. You can not do inheritance in structures.
? Structures do not require constructors while classes require.
? Objects created from classes are terminated using Garbage collector. Structures are not destroyed using GC.

2007-10-23, 6138👍, 0💬