Thursday, 10 December 2015

What is the Difference Between Class and structure

Posted by

Class

  •  Class is a written description of and object.
  • Class is a user define data types.
  • Class is a blue print of and objects
  • Class contain data and behaviors.
  • Class is the attributes of the objects.
  • Class is a logical entity.
  • A class is reference type.
  • While instantiating a class, CLR allocates memory for its instance in heap.
  • classes support inheritance
  • Variable of class assigned as null.
  • Class can contain constructor/destructor.


Structure

    • A structure is a value type.
    • In structure, memory is allocated on stack
    • Structures do not support inheritance.
    • Structure members cannot have null values.
    • Structure does not require constructor/destructor and members can be initialized automatically.


0 comments:

Post a Comment