OOP & concepts

string vs String in C#: is there any difference?

OOP & concepts · · Published 2026-08-09

There is no difference in behaviour: string is a C# keyword that is an alias for the .NET type System.String. Both spellings compile to exactly the same thing. The choice is a matter of style, with one or two technical corners.

Same type

string a = "hello";
String b = "hello";             // needs 'using System;' (or global usings)
System.String c = "hello";

Console.WriteLine(a.GetType() == typeof(String));   // True
Console.WriteLine(typeof(string) == typeof(System.String)); // True

Static members are reachable through either name: string.IsNullOrEmpty(x) and String.IsNullOrEmpty(x) are the same call.

Where the spellings differ

The other aliases

C# keyword.NET type
stringSystem.String
objectSystem.Object
boolSystem.Boolean
int / long / short / byteInt32 / Int64 / Int16 / Byte
double / float / decimalDouble / Single / Decimal
charChar
nint / nuintIntPtr / UIntPtr

The .NET name is useful in method names that describe a type, as the framework itself does: Convert.ToInt32, reader.GetInt64, not ToInt.

Which to use?

Microsoft's C# coding conventions recommend the language keywords (string, int) rather than the runtime type names for declarations and member access, and the default code-style rule IDE0049 in Visual Studio suggests the same. Some teams prefer String.Format for static calls; what matters is consistency within a code base, enforced by an .editorconfig setting.

A more substantial question about strings is mutability: see string vs StringBuilder.

A note on VB.NET

Visual Basic has the same arrangement: String (with a capital letter, as VB keywords are written) is a keyword alias for System.String, just as Integer maps to System.Int32. Code that mixes C# and VB.NET projects therefore uses one type throughout; only the spelling differs between the languages. In both, string comparison rules (ordinal, culture-aware, case-insensitive) matter far more in practice than which alias you type: pass a StringComparison value to Equals, StartsWith and IndexOf to make the intent explicit.

Official documentation