Differences between string and String in C#

Want create site? Find Free WordPress Themes and plugins.

string is an alias in C# for System.String. So technically, there is no difference. It’s like int vs. System.Int32.

It is generally recommended to use string any time you’re referring to an object.  For example,

string place = "world";

Likewise, it is generally recommended to use String if you need to refer specifically to the class. For example,

string greet = String.Format("Hello {0}!", place);

Here is a complete list of C# type aliases.

object:  System.Object
string:  System.String
bool:    System.Boolean
byte:    System.Byte
sbyte:   System.SByte
short:   System.Int16
ushort:  System.UInt16
int:     System.Int32
uint:    System.UInt32
long:    System.Int64
ulong:   System.UInt64
float:   System.Single
double:  System.Double
decimal: System.Decimal
char:    System.Char
Did you find apk for android? You can find new Free Android Games and apps.

Leave a Reply

Be the First to Comment!

Notify of