解决方案

System.String是C中的.NET字符串类。string是System.String的别名,因此在使用中它们是相同的。
从技术上讲,没有区别。就像intSystem.Int32一样。

就准则而言,通常建议我们在每次引用对象时都使用"string"。

例如

string place = "world";

同样,我认为如果需要专门引用该类,通常建议使用String

例如

string greet = String.Format("Hello {0}!", place);
C#中String 和 string有什么区别?

比如

string s = "Hello world!";
String s = "Hello world!";
日期:2020-03-25 13:28:07 来源:oir作者:oir