string
is an alias in C# for System.String
. So technically, there is no difference. It's like int
vs. System.Int32
.
But int automatically references
System.Int32
because it is the default, while there are many other integer(int
) types. Using int
just defaults to the 32 bit integer if you don´t explicitly tell in your code what type of integer it should expect. If you reference Int16
instead of int, you will specify the type from the default Int32
.
As far as guidelines, I think it's generally recommended to use
string
anytime you're referring to an object.
e.g.
string place = "world";
Likewise, I think it's generally recommended to use
String
if you need to refer specifically to the class.
e.g.
string greet = String.Format("Hello {0}!", place);
No comments:
Write comments