Similarities and difference between Class and structure in .NET

Similarities and difference between Class and structure in .NET.


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


- 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.
Features of Static/Shared classes.
Static classes are used when any change made to an object should not affect the data and functions of the class....
What is Operator Overloading in .NET?
Operator overloading is the most evident example of Polymorphism.....
What is Finalize method in .NET?
Object.Finalize method in .NET is typically used to clean and release unmanaged resources like OS files, window etc....
Post your comment