Why can't I *override* and *new* a Property (C#) at the same time?
- by Tim Lovell-Smith
According to this question it seems like you can do this for Methods. What I want to know is why it doesn't work when I try it with properties.
public class Foo
{
public virtual object Value
{
get;
set;
}
}
public class Foo<T> : Foo
{
public override object Value
{
get
{
return base.Value;
}
set
{
base.Value = (T)value; //inject type-checking on sets
}
}
public new T Value
{
get { return (T)base.Value; }
set { base.Value = value; }
}
}
Error message from C# 4.0 RC1
Error 1 The type 'ClassLibrary1.Foo' already contains a definition for 'Value' ClassLibrary1\Class1.cs 31 22 ClassLibrary1