Skip to content

Instantly share code, notes, and snippets.

@cowlike
Last active October 7, 2015 04:17
Show Gist options
  • Save cowlike/3104111 to your computer and use it in GitHub Desktop.
Save cowlike/3104111 to your computer and use it in GitHub Desktop.
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