string vs System.String in C#
This is one of the frequently asked C# interview question for the beginners. This is very simple but confusing question during interview. In this article I will explain difference between string and System.String in C#.
Actually there is no difference between string
and String
. string
is just an alias created by Microsoft for System.String
. string
stands for System.String
. This alias name is provided so that you don’t need to type every time System.String
, you can simply use string in place of it.
Both of them compiled into same code (IL Code – System.String) and within same during execution time.
Let’s understand by an example:

In this example I have taken 2 variables, one is string
type and second is System.String
type. When I hover mouse on string keyword, it specifies that it refers to System.String.
For using String
instead of System.String
, you need to include System
namespace by using keyword.
Not let’s have a look in Intermediate Language (IL) for this code:

You can see in image, both are same in Intermediate Lanaguage (IL) as well.
string
and String
are not alone, Microsoft has provided similar aliases for other C# data type as well:
Alias Name | C# Data Type |
---|---|
bool | System.Boolean |
byte | System.Byte |
sbyte | System.SByte |
char | System.Char |
decimal | System.Decimal |
double | System.Double |
float | System.Single |
int | System.Int32 |
uint | System.UInt32 |
long | System.Int64 |
ulong | System.UInt64 |
object | System.Object |
short | System.Int16 |
ushort | System.UInt16 |
string | System.String |