C#中的String和string | 狂野铜匠

C#中的String和string

时间:2010-9-19  |   0  |  标签:, ,

String是CLR中的类型而string是C#中的类型

string不能作为类、结构、枚举、字段、变量、方法、属性的名称而String可以

通过C#编译时的默认增加的几行代码,你会看出两者的区别:

using string = System.String;
using sbyte = System.SByte; 
using byte = System.Byte; 
using short = System.Int16; 
using ushort = System.UInt16;
using int = System.Int32; 
using uint = System.UInt32;

还有许多类似的类型。有的没有对应的类型,这时使用的就是.NET的,比如说在C#中没有date类型,所以在C#中我们使用.NET 的DateTime. 这也是.NET的跨语言特性之一。





无觅相关文章插件,快速提升流量