关于全球化Convert.ToString方法和Object.ToString()之间的区别区别、方法、Convert、ToString

2023-09-04 05:04:28 作者:跟上这个节奏跟我一起摇

有没有用C#.net以外的其他如何将这些处理空值Convert.ToString方法和Object.ToString()之间的差异。 有可能是在全球化视野下,两者之间存在差异。

Is there any difference between Convert.ToString Method and Object.ToString() in C#.net other than how these handle null value. There could be some difference between the two in Globalization Perspective.

推荐答案

YES和NO。

例如, Convert.ToString(INT)的方法,是相同的 Int32.ToString()方法,如在备注部分 MSDN规定:这个实现是相同的Int32.ToString()。的不过,转换类还提供覆盖其采取的IFormatProvider 作为第二个参数(如 转换。的ToString(整型,IFormatProvider的) 的),并且这可以用来调整输出格式,例如通过传递的CultureInfo 实例。

For example, the Convert.ToString(int) method, is identical to the Int32.ToString() method, as MSDN states in the 'Remarks' section: "This implementation is identical to Int32.ToString()." However, the Convert class also offers overrides which take an IFormatProvider as a second parameter (e.g. Convert.ToString(int, IFormatProvider)), and this can be used to adjust the output format, e.g. by passing a CultureInfo instance.