String vs string [duplicate]
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.
精彩评论