How class and a structure are different

How class and a structure are different?

E

Expert

Verified

a.) Class:

  • The class is a reference type.
  • During instantiating the class, CLR assigns memory for its instance in heap.
  • Class supports inheritance.
  • Variables of the class could be allotted as null.
  • It can contain constructor or destructor.


b.) Structure:

  • The structure is a value type.
  • Memory is assigned on stack.
  • It does not support inheritance.
  • Members of Structure could not have null values.
  • It do not need constructor or destructor and members could be initialized automatically.

   Related Questions in Programming Languages

©TutorsGlobe All rights reserved 2022-2023.