Last active
August 29, 2015 14:13
-
-
Save SriramSakthivel/bb37b39157422ad2da8d to your computer and use it in GitHub Desktop.
Code snippet for the blog post https://sriramsakthivel.wordpress.com/2015/01/11/breaking-the-clr-type-safety-part-two-2/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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