示例(注意情况):
string s = "Hello world!";
String s = "Hello world!";
每种使用的准则是什么?有什么区别?
string
是C#中的别名System.String
。
因此,从技术上讲,没有区别。这就像int
对 System.Int32
。
就准则而言,通常建议string
您在引用对象时使用任何时间。
例如
string place = "world";
同样,我认为String
如果需要专门引用该类,通常建议使用。
例如
string greet = String.Format("Hello {0}!", place);
似乎此区域中的指南可能已更改,因为StyleCop现在强制使用C#特定别名。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句