What is the difference between String and string in C#?


String stands for System.String whereas string is an alias in C# for System.String −

For example

string str = "Welcome!";

It’s not essential, but generally String is used when you work with classes.

string str = String.Format("Welcome! {0}!", user);

Since the string is an alias for System. String. The alias for other datatypes are −

Example

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

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 21-Jun-2020

344 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements