Sometimes there is a need to create duplicateinstances of a same class ( objects with same values for the properties, and fields. )
When the class is of known type, it’s easy to duplicate the instances.
For e.g.:
Consider a class called MyClassExample
Class MyClassExample { public int NUMBER1 {get; set;} public int NUMBER2{get; set;} public int number3; public int number4; }
Now we create an instance:
MyClassExample obj1 = new MyClassExample{NUMBER1 =5;NUMBER2 =6; number3 = 7; number4=8 };
To create the duplicate instance, and add it to a collection, we can write like
for(int i=0; i