开发者

In C# what is the difference: string vs String [duplicate]

开发者 https://www.devze.com 2022-12-20 00:39 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: In C# what is the difference between String and string
This question already has answers here: Closed 12 years ago.

Possible Duplicate:

In C# what is the difference between String and string

In C# there is string and there is System.String.

What is the difference between these? Is one considered better to use that the other. Are there any hidden dangers in mixing the use of them?

开发者_如何学GoIf they are the same, then why have them both? Why not just have one or the other?


System.String is the name of the actual .NET CLR class, just like System.Int32 is the real name of that class. But the designers of C# wanted it to look a lot like C and C++, where the native types (like int) are in lower case, so they added aliases for the basic native types.


There is no difference.

http://msdn.microsoft.com/en-us/library/362314fe.aspx

The string type represents a sequence of zero or more Unicode characters. string is an alias for String in the .NET Framework.


No difference string is an alias for String. See here

For more information, see the following sections in the C# Language Specification:

2.4.2 Identifiers

2.4.4.5 String literals

4.2.3 The string type

7.9.7 String equality operators


string is just an alias for System.String

0

精彩评论

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