首先运用MSDN官网的解释:The string type represents a string of Unicode characters. string is an alias for System.String in the .NET Framework.
说的是string类型其实代表了一种统一编码的特性,在.net framwork 中"string"是System.String的一个别名而已。
C# defines a number of aliases for CLR types. They may be used interchangably, and even mixed together, e.g.
string x = new System.String(' ', 5);
.
These are the aliases defined:
Alias | CLR type |
---|---|
string | System.String |
sbyte | System.SByte |
byte | System.Byte |
short | System.Int16 |
ushort | System.UInt16 |
int | System.Int32 |
uint | System.UInt32 |
long | System.Int64 |
ulong | System.UInt64 |
char | System.Char |
float | System.Single |
double | System.Double |
bool | System.Boolean |
decimal | System.Decimal |
说在C#中为CLR类型定义了很多的别名,说明string其实和String的用法一样,只不过是不同程序员的使用习惯罢了。我也看了一些别人的理解,string其实在C#语言中是一种标记,也就是string是C#中的关键字他代表了framwork中的String类型,所以毫无疑问既然是关键字string就不能作为其他任何类型变量的名字了。编译器在解释的时候吧string编译为String类型,由此可见如果用String就能减少编译器的一些负担,提高运行效率。
推荐一个详细的地址:http://www.cnblogs.com/aidd2008/archive/2008/12/07/1349269.html