Last active
October 7, 2015 04:17
-
-
Save cowlike/3104111 to your computer and use it in GitHub Desktop.
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
using System; | |
namespace extensions | |
{ | |
class Foo | |
{ | |
private int myInt = 3; | |
virtual public int MyInt | |
{ | |
get { return myInt; } | |
} | |
} | |
class ChildFoo : Foo | |
{ | |
private int testInt = 0; | |
public new int MyInt | |
{ | |
get { return testInt; } | |
set { testInt = value; } | |
} | |
} | |
class Program | |
{ | |
static void showFoo(Foo f) | |
{ | |
Console.WriteLine("i = " + f.MyInt); | |
} | |
static void Main(string[] args) | |
{ | |
var f = new ChildFoo(); | |
showFoo(f); | |
f.MyInt = 99; | |
showFoo(f); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment