object 的tostring()
在.net中是这样定义的:
public virtual string ToString()
{
return this.GetType().ToString();
}对于其他类型会重载方法。
但是对于object来说。
this.GetType()还是object.
object 的tostring的方法.是虚方法.对于object是怎么重载执行此方法呢?
对语言的理解太浅.希望明白人讲讲.
在.net中是这样定义的:
public virtual string ToString()
{
return this.GetType().ToString();
}对于其他类型会重载方法。
但是对于object来说。
this.GetType()还是object.
object 的tostring的方法.是虚方法.对于object是怎么重载执行此方法呢?
对语言的理解太浅.希望明白人讲讲.
// Print the String Representation of the Type
public override String ToString()
{
return "Type: "+Name;
}
谢谢。到GetType()这里又看不懂了。
他是怎么样判断object的类型的呢?.net只有下面代码
[MethodImpl(MethodImplOptions.InternalCall)]
public extern Type GetType();