Objects in this mirror are closer to Microsoft Technologies. DNM objective is to help users on Microsoft technologies by providing Articles, snippets, Interview Questions.

25 June 2012

Difference between Class and Structure in .NET


In this article we will see what are all the differnece between a class and structure.

Structure
Class
Value type
Reference type
After instantiation memory will be created on stack.
After instantiation memory will be created on heap
Does not Support inheritance. But can implement interfaces
Supports inheritance and implementation of interfaces
Does not support default( parameter less )constructor
It supports default(parameter less) constructor
Cannot define destructor
Can have destructor
Does not permit initialization of instance fields with in definition
Permits initialization of instance fields with in definition
On assignment values data is copied
On assignment copies the reference
Memory deallocation done when they go out of scope
Memory deallocation handled by garbage collector.

0 Comments:

Post a Comment