diff --git a/docs/csharp/language-reference/keywords/protected.md b/docs/csharp/language-reference/keywords/protected.md index 5d03de0f8df41..b81bbf41809d1 100644 --- a/docs/csharp/language-reference/keywords/protected.md +++ b/docs/csharp/language-reference/keywords/protected.md @@ -26,7 +26,7 @@ A protected member of a base class is accessible in a derived class only if the [!code-csharp[csrefKeywordsModifiers#11](~/samples/snippets/csharp/VS_Snippets_VBCSharp/csrefKeywordsModifiers/CS/csrefKeywordsModifiers.cs#11)] -The statement `a.x = 10` generates an error because it is made within the static method Main, and not an instance of class B. +The statement `a.x = 10` generates an error because it accesses the protected member through a base class reference (`a` is of type `A`). Protected members can only be accessed through the derived class type or types derived from it. Struct members cannot be protected because the struct cannot be inherited. diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csrefKeywordsModifiers/CS/csrefKeywordsModifiers.cs b/samples/snippets/csharp/VS_Snippets_VBCSharp/csrefKeywordsModifiers/CS/csrefKeywordsModifiers.cs index 73ac9eac4848d..7c058a3e6ab73 100644 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csrefKeywordsModifiers/CS/csrefKeywordsModifiers.cs +++ b/samples/snippets/csharp/VS_Snippets_VBCSharp/csrefKeywordsModifiers/CS/csrefKeywordsModifiers.cs @@ -345,8 +345,8 @@ static void Main() var a = new A(); var b = new B(); - // Error CS1540, because x can only be accessed by - // classes derived from A. + // Error CS1540, because x can only be accessed through + // the derived class type, not through the base class type. // a.x = 10; // OK, because this class derives from A.