[每日高赞翻译stackoverflow](1)string 和 String 的区别

来源:互联网 发布:淘宝cpu散片哪家靠谱 编辑:程序博客网 时间:2024/05/17 06:18

本人翻译水平不怎么样,如果有错误请各位大大提出来


来源:https://stackoverflow.com/questions/7074/what-is-the-difference-between-string-and-string-in-c

如果你认同他的看法或者有所帮助,可以到网站为他点个赞


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#具体的别名的用法,表现出这种引导可能随时会改变



-----------------------------------------------------

译者总结:

两个没区别


阅读全文
0 0