
Sometimes when I call the
ToStringmethod it returns the fully qualifIEd name of the runtime type of the object that received the call.
正确.
But for some types,such as
system.int32,ToStringreturns the value of the receiver converted to a string.
正确.
Does the
system.int32struct overrIDe theToStringmethod?
是.
Do other types whose
ToStringmethods return the fully-qualifIEd type name not overrIDeToString?
情况可能就是这样,是的.当然,他们可以覆盖该方法并使覆盖方法与基类方法完全相同,但这有点无意义.
So in those cases,calling
ToStringjust calls theSystem.Objectimplementation ofToString,which returns fully qualifIEd name?
正确.
你似乎已经掌握了它是如何工作的.我唯一的修正是要注意system.int32是一个结构,而不是一个类.
总结以上是内存溢出为你收集整理的c# – .ToString()方法如何工作?全部内容,希望文章能够帮你解决c# – .ToString()方法如何工作?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)