Skip to content

Instantly share code, notes, and snippets.

@DForshner
Created July 4, 2013 15:18
Show Gist options
  • Save DForshner/5928569 to your computer and use it in GitHub Desktop.
Save DForshner/5928569 to your computer and use it in GitHub Desktop.
Implementing ICloneable
public class ImplementingICloneable : ICloneable
{
/// <summary>
/// Returns a clone of the current object.
/// </summary>
public ImplementingICloneable Clone()
{
return (ImplementingICloneable)this.MemberwiseClone(); // MemberwiseClone() only creates a shallow copy.
}
object ICloneable.Clone()
{
return Clone();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment