-3

The Object is the base class from which every other class is derived. Among others it has methods with Protected access modifier (i.e. MemberwiseClone()).
protected means that the member is accessible from within the class in which it is declared, and from within any class derived from the class that declared this member.

Does that mean that for Object all protected members will be public in fact? And if yes, why is it implemented?

Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
  • 2
    It is protected because it is a dangerous method. Only the class itself could determine whether a shallow copy is appropriate. – Hans Passant Apr 16 '18 at 15:06
  • 1
    `protected members will be public in fact` that's not true. There is a difference between public and protected. Protected members can not be accessed from outside the class. – Chetan Apr 16 '18 at 15:07

1 Answers1

-2

No it does not mean they will be public. It means that any class that derives from that class can use the protected methods.

public class A
{
    private void PrivateMethod() {  /*can be seen only here */ }
    protected void ProtectedMethod() {  /*can be seen here and by anyone deriving from me (A) */ }
    internal void InternalMethod() {  /*can be seen here and by anyone in the same assembly with me. */ }
    public void PublicMethod() {  /*can be seen here and by anyone else. */ }
}
Michael Puckett II
  • 6,586
  • 5
  • 26
  • 46