开发者

String or string [duplicate]

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

Possible Duplicate:

In C# what is the difference bet开发者_如何学Cween String and string

what's the difference between the String and string. In C#, which is preferred?


Actually string is an alias for System.String but erash is basically right...

Here is a list of other alias' shamelessly lifted from Jon Skeet in this post:

* object: System.Object
* string: System.String
* bool: System.Boolean
* byte: System.Byte
* sbyte: System.SByte
* short: System.Int16
* ushort: System.UInt16
* int: System.Int32
* uint: System.UInt32
* long: System.Int64
* ulong: System.UInt64
* float: System.Single
* double: System.Double
* decimal: System.Decimal
* char: System.Char


They are the same this, string is an alias for String.

I tend to use String when calling static methods (i.e., String.Format(...) or String.IsNullOrEmpty(...). I don't know why, I just do.


string is just an alias for String -- they are the same

edit: type fixed


string is a C#-specific keyword that means the same thing as the System.String type. Prefer the language keywords where possible, so use e.g. string, int, float, instead of System.String, System.Int32, System.Single.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜