c#: String class vs string struct
Possible Duplicate:
What's the difference between String and string?
I have been some time working with C# and i have ever noticed any diference between both types.
String myStringAsClass;
string myStringAsStruct;
Is there any diference other than the clarification you may use on the code or convetion to use the static functions from String class and declarations from string struct?
Thank you very much!
They are the same. They are both reference types.
System.String == string
System.Object == object
System.Int32 == int
System.Int64 == long
...etc.
string
是System.String
的别名,就像int
是System.Int32
的别名一样。
There IS a difference between a class and a struct in C#. However that is irrelevant here since
String == string
and both are class
So, to summarize, there is NO difference between the two, and string
is a class.
上一篇: 布尔和布尔在C#之间的区别?
下一篇: c#:String类与字符串结构