string
is an alias in C# for System.String
. So technically, there is no difference. It's like int
vs. System.Int32
.
string 类型是System.String的别名。所以从技术上来讲,他们没有区别。就像 int 和 System.Int32
As far as guidelines, I think it's generally recommended to use string
any time you're referring to an object.
仅仅作为引导,我推荐 与对象有关的时候用string。
e.g.
string place = "world";
Likewise, I think it's generally recommended to use String
if you need to refer specifically to the class.
像这样,我推荐 与类有关的时候用String
e.g.
string greet = String.Format("Hello {0}!", place);
This is the style that Microsoft tends to use in their examples.
这也是微软倾向使用的风格
It appears that the guidance in this area may have changed, as StyleCop now enforces the use of the C# specific aliases.
stylecop现在实施这种c#具体的别名的用法,表现出这种引导可能随时会改变