Say you have the following code:
interface Foo
{
public int Value { get; set; }
}
class Bar : Foo
{
public int Value { get; set; }
}
Now suppose I'd like to give the Value property a more sensible name in Bar, like BarValue (I can imagine this is not uncommon, since interfaces might have very generalized property names so that the naming in deriving classes is suboptimal for readability). Is it possible to give Value an alias, so the Bar class looks sort of like this:
class Bar : Foo
{
public int Value as BarValue { get; set; }
}
So that I can access the property like this:
Bar bar = new Bar();
//Calling Value as normal
Console.WriteLine(bar.Value);
//Calling the same property, Value, but using its alias
Console.WriteLine(bar.BarValue);
My question is: is this possible? I know you can achieve the same thing doing it like this:
class Bar : Foo
{
public int Value { get; set; }
public int BarValue { get => Value; set => Value = value; }
}
But this is less neat. Thanks in advance.