Example :
string s = "uday";
String S = "uday";
string is an alias for System.String. So technically, there is no
difference. It's like int vs. System.Int32.
string is a c sharp keyword.
It is
recommended to use string any time when you're referring to an object.
e.g : string
name = "uday";
Where as use
String if you need to refer specifically
to the class. e.g.
string
firstname= String.Format("Uday" {0}!", name);
This is the
style that Microsoft tends to use in their examples
Note: You
must have to include a using System when using String, otherwise you get the
following error:
The type or
namespace name 'String' could not be found (are you missing a using directive
or an assembly reference?)
These are
the aliases defined:
Alias CLR type
string System.String
sbyte System.SByte
byte System.Byte
Note: String represents the System.String class while the string is the keyword for the System.String that we can use to create string objects.
Note: String represents the System.String class while the string is the keyword for the System.String that we can use to create string objects.
No comments:
Post a Comment
Thank you for visiting my blog