Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
很抱歉这个愚蠢的问题,但我最近发现你可以在 C# 中声明一个字符串或字符串变量。我想知道它们之间的区别,在特定情况下使用哪一个,等等。感谢您的帮助和您的时间。
没有区别String的是类名和string别名。
String
string
我遵循的一般经验法则是,如果您声明一个变量,请使用别名。
string foo = "bar";
如果调用方法,请使用类名
String.IsNullOrEmpty("");
以下是完全一样的"
ETC