开发者

String vs string [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicate:

In C# what is the difference between String and str开发者_如何学编程ing

Should I use string or String when declaring a basic string variable in c# and does it matter?


I like string because VS highlights it in dark blue (which makes it awesomer).


It doesn't matter, though it's best to be consistent: lower-case string is an alias for String.


The string keyword is an alias for System.String.

(The same goes for int - System.Int32 long - System.Int64 and so on)

C# doesn't have two different representations for primitives the same way that Java does. (Where an int is far different from an Integer)

In most cases it is best to use lowercase string because it is an alias to the fully qualified System.String. This way you can avoid type conflicts if there is another String type somewhere in your code.


They both point to the same class. It doesn't matter which one you use.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜