c#是区分大小写的呀,为何 new String() 与 new string() 效果完全相同呢? char[] s = { 'a','b','c','d','!'};
string str;
str = new String(s);
Console.WriteLine(str);
string str1 = new string(s);
Console.WriteLine(str1);
正规的写法:应该写成 new String() 呢,还是写成 new string() 才规范呀?
string str;
str = new String(s);
Console.WriteLine(str);
string str1 = new string(s);
Console.WriteLine(str1);
正规的写法:应该写成 new String() 呢,还是写成 new string() 才规范呀?
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; ... ...
string是.NET Framework中给它设定的别名, 是一个关键字,效果是一样的
这么说, String才是正名呀。
可是又说 string 是c#的关键字,String竟然不是c#的关键字。到底 String ,string ,谁是最根本的呀?
使用string不需要引用任何命名空间。这就是String和string的唯一区别
+1 正解
看东西不能看表面 你深入的去FW 了解 多去MSDN 搜搜
String本身是类型,
而string的行为伪装的像个值,为的是让程序员方便使用具体参见MSDN的 string(C# 参考):
http://msdn.microsoft.com/zh-cn/library/362314fe(VS.80).aspx