int a = 2;
Console.WriteLine(a.ToString()); // displays 2
// definition of ToString() here - public override string ToString();
现在,这是我的一些理解:
ToString()
方法,该方法从Object
类继承而来。int
是一种Int32
类型的结构,它从接口中获取几个带参数的方法,它在结构Int32
中也是一个不带参数函数的ToString()
根据http://msdn.microsoft.com/en-us/library/system.int32.tostring.aspx的说法,
结构Int32覆盖ValueType.ToString()方法
如果一个结构不能继承某些类或结构,您能解释一下这个ToString()
方法如何可用于Int32
吗
https://stackoverflow.com/questions/10727151
复制相似问题