Tutorial by Examples

Implement ICloneable in a class with a twist. Expose a public type safe Clone() and implement object Clone() privately. public class Person : ICloneable { // Contents of class public string Name { get; set; } public int Age { get; set; } // Constructor public Person(string...
The implementation of ICloneable for a struct is not generally needed because structs do a memberwise copy with the assignment operator =. But the design might require the implementation of another interface that inherits from ICloneable. Another reason would be if the struct contains a reference t...

Page 1 of 1