1.

Similarities And Difference Between Class And Structure In .net

Answer»

Similarities:

  • Both Class and Structures can have methods, variables and objects.
  • Both can have constructor.
  • Both are user defined types.

DIFFERENCES:

  • STRUCTURE being value type, the variables cannot be assigned to NULL. On the other hand, CLASSES being REFERENCE type, a class variable can be assigned to NULL.
  • Structure is allocated on a stack when instantiated, while Class is allocated on a heap.
  • When a method is passed to a class, PASS by reference is used. Pass by value is used for struts.
  • A class can have a destructor.

Similarities:

Differences:



Discussion

No Comment Found