Sunday 17 June 2018

String vs string, Int vs int in c#

Normally people find it confusing while thinking about whats the difference between String and string, Int and int and so on. There is no difference but a slight change of mindset in their writing style. It's recommended by the Microsoft to use "string" when you are referring to an object, in short string is an alias for System.String. So it doesn't matter whether you use System.String or string in your c# sharp code, both are same in terms of execution and performance perspectives and same is the case with int and System.Int32 The complete list of other such objects is mentioned below

string:  System.String
int:     System.Int32
object:  System.Object
bool:    System.Boolean
byte:    System.Byte
sbyte:   System.SByte
short:   System.Int16
ushort:  System.UInt16
uint:    System.UInt32
long:    System.Int64
ulong:   System.UInt64
float:   System.Single
double:  System.Double
decimalSystem.Decimal
char:    System.Char

No comments:

Post a Comment