Class and Structure

State the difference between a class and a structure?

E

Expert

Verified

Class :

a) A class is a reference type.
b) While instantiating a class, CLR assigns memory for its instance in heap.
c) Variables of class can also be allocated as null.
d) Classes also support inheritance.
e) Class contains constructor/destructor.

Structure :

a) A structure is a value type.
b) In structure, memory is allocated on the stack.
c) Structure members cannot have null values.
d) Structures do not support inheritance.
e) Structure does not need any constructor/destructor and members are initialized automatically.

   Related Questions in DOT NET Programming

©TutorsGlobe All rights reserved 2022-2023.