Tuesday 20 November 2012

How to Prevent a class being Insiated in c#

Their are many ways to Doing
1- Make The Class Abstract
2- Use Static Class
3- Make Private Constructor

Difference Between Shallow Copy & Deep Copy

Shallow Copy:  In Shallow copy, the Second object is attached to same memory block. hence any change in either will reflect in Second one. This is faster than deep copy.

Deep Copy:  In Deep copy, Structure and data is copied and both behave as two objects.

Example :  System.Array.CopyTo() and System.Array.Clone()




System.Array.Clone() creates a shallow copy

while System.Array.CopyTo()  creates a deep copy