I'm trying to hide accessors in a derived class, is it really? My system did not respond.
class BaseCS
{
private string name;
public string Name
{
get { return name; }
set { name = "Base " + value; }
}
}
class DerivedCS : BaseCS
{
public new string Name
{
set { Name = "Der " + value; }
get { return Name; }
}
}
public static void Main()
{
BaseCS one = new DerivedCS();
one.Name = "One";
Console.WriteLine("Name of object one is {0} ", one.Name);
((BaseCS)one).Name = "On1";
Console.WriteLine("Name of object one is {0} ", one.Name);
}
Should I expect a conclusion
Name of object one is Base Der One
Name of object one is Base On1
source
share