String vs string
In C# there are String
objects and string
objects.
What is the difference between the two? What are the best practices regarding which to use?
There is no difference. string (lower case) is just an alias for System.String.
No difference. System.String
is strictly identical to string
. Common C# coding guidelines indicates that you should use the keyword string
.
They are aliases and are interchangeable. However, stylistically, for declarations, I use the lowercased string, and for the static methods, I use String.
string foo = "bar";
if( foo != String.Empty )
{
Console.WriteLine(String.Format("foo.Length = {0}", foo.Length));
}
链接地址: http://www.djcxy.com/p/3590.html
上一篇: 字符串与字符串
下一篇: 字符串与字符串