Skip to content

Instantly share code, notes, and snippets.

@SriramSakthivel
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SriramSakthivel/bb37b39157422ad2da8d to your computer and use it in GitHub Desktop.
Save SriramSakthivel/bb37b39157422ad2da8d to your computer and use it in GitHub Desktop.
class A
{
protected int x = 123;
}
class B : A
{
static void Main()
{
A a = new A();
B b = new B();
// Error CS1540, because x can only be accessed by
// classes derived from A.
// a.x = 10;
// OK, because this class derives from A.
b.x = 10;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment