这两者之间有什么区别,我应该使用哪一个?
string s = "Hello world!";
String s = "Hello world!";
这两者之间有什么区别,我应该使用哪一个?
string s = "Hello world!";
String s = "Hello world!";
当前回答
字符串是 System.String 的简称,字符串或 System.String 是 CTS(通用类型系统)中的字符串的名称。
其他回答
它已被覆盖; 但是,你不能在反射中使用线条; 你必须使用线条。
标签: 代表一类
字符串: 代表一个 alias
这只是微软的编码协议。
基本上,在 C# 中,线和线之间没有区别。
String 是 System.String 中的.NET 框架中的一个类,而较低的案例字符串则是 System.String 的标志。
登录两个类型的完整名称可以证明这一点
string s1= "hello there 1";
String s2 = "hello there 2";
Console.WriteLine(s1.GetType().FullName); // System.String
Console.WriteLine(s2.GetType().FullName); // System.String
大多数开发人员使用字符串在C#中声明变量,并使用System.String类使用任何内置的字符串方法,例如,String.IsNullOrEmpty()方法。
两者之间没有区别,您可以在代码中使用其中一个。
System.String 是一个类(参考类型)定义的 mscorlib 在名空间系统. 换句话说, System.String 是 CLR 的类型。
string 是 C# 的关键词
String(System.String)是基类图书馆的一个类。 string(下一个案例)是C#的备份工作,这是System.String的标志。 Int32 vs int是一种类似的情况,如Boolean vs. bool. 这些C#语言特定的关键词允许您以类似于C的风格宣布原始性。