By the way, the answer is this:
string _str = "WORLD";
System.Console.Write(_str);
System.Console.Write(base._str);
Paradoxically, this will have the same effect:
string _str = "WORLD";
System.Console.Write(_str);
System.Console.Write(this._str);
but this is because there is no another
_str
as a class member; the new
_str
is a stack variable. Consider this:
class xyz : abc {
new string _str = "HIDES BASE _str";
public void add()
{
string _str = "WORLD";
System.Console.Write(_str);
System.Console.Write(this._str);
System.Console.Write(base._str);
}
The keyword
new
above is only used to prevent warning about hiding of base
_str
, and such hiding is indeed bad style.
Please understand these simple techniques and be considerate to people helping you. Yes, that was a lecture — thank you for attention. :-)
—SA