In
C#, what is the difference between String and string?
Example:
string
s = "Hello, World";
String
S = "Hello, World";
string
is an alias for System.String. So technically, there is no difference. It's like
int vs. System.Int32. As far as guidelines, I think it's generally recommended
to use string any time you're referring to an object.
Example:
string place = "world";
Likewise,
I think it's generally recommended to use String if you need to refer specifically
to the class.
Example:
string
greet = String.Format("Hello {0}!", place);
Comments
Post a Comment