"String" is an alias ( the same thing called with different names) of "string". So technically both the below code statements will give the same output.
String s = "C# interview questions";or
string s = "C# interview questions";
In the same way there are aliases for other c# data type as shown below:- 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
Difference:
When we talk about .NET there are two different things one there is .NET framework and the other there are languages ( C# , VB.NET etc) which use that framework.
"System.String" => "String" ( capital "S") is a .NET framework data type while "string" is a C# data type.
when we should use "String" & "string":
First thing to avoid confusion use one of them consistently. But from best practices perspective when you do variable declaration it's good to use "string" ( small "s") and when you are using it as a class name then "String" ( capital "S") is preferred.
In the below code the left hand side is a variable declaration and it declared using "string". At the right hand side we are calling a method so "String" is more sensible.
In the below code the left hand side is a variable declaration and it declared using "string". At the right hand side we are calling a method so "String" is more sensible.
string s = String.ToUpper() ;