Search code examples
c#cloneprotected

Object Class's protected method MemberWiseClone()


This might be a dumb question, but I don't get it:

I have a class called Card. I want to do a shallow clone using MemberWiseClone(). In Theory Card inherits from Object. So it should be able to use MemberWiseClone(), even if MWC() is protected ??

Am I missing/forgetting something?


Solution

  • Card can use it.

    class Card
    {
       public Card Clone()
       {
          return (Card)MemberwiseClone();
       }
    }