The type System.String
, like almost all types in .NET, derives from System.Object
. Object
has a ToString()
method and so String
inherits this method. It is a virtual method and String
overrides it to return a reference to itself rather than using the default implementation which is to return the name of the type.
From Reflector, this is the implementation of ToString in Object
:
public virtual string ToString()
{
return this.GetType().ToString();
}
And this is the override in String
:
public override string ToString()
{
return this;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…