There is no major difference between string
and String
in C#.
String
is a class in the .NET framework in the System namespace. The fully qualified name is System.String
. The lower case string is an alias of System.String
.
But its recommended to use string
while declaring variables like:
string str = "Hello";
And we can use String
while using any built-in method for strings like String.IsNullOrEmpty()
.
Also one difference between these two is like before using String
we have to import system namespace in cs file and string
can be used directly.