<分区>
Possible Duplicate:
Difference between Convert.tostring() and .tostring()
你好
从这个问题继续What is the difference between Convert and Parse?
这里有两行代码。
Convert.ToString(myObject);
myObject.ToString();
我的问题是有什么区别,哪种最好用?
提前谢谢你。
<分区>
Possible Duplicate:
Difference between Convert.tostring() and .tostring()
你好
从这个问题继续What is the difference between Convert and Parse?
这里有两行代码。
Convert.ToString(myObject);
myObject.ToString();
我的问题是有什么区别,哪种最好用?
提前谢谢你。
最佳答案
它们之间的基本区别是 Convert
函数处理 NULL
而 i.ToString()
才不是。它将抛出一个 NULL
引用异常错误。因此,作为良好的编码习惯,使用
Convert
总是安全的。
关于c# - 转换字符串之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3500485/