What is the difference between String and string in C#?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
In C#, string and String refer to the same .NET type: System.String. The difference is mostly about language syntax and coding style, not runtime behavior.
That said, the distinction still matters because it affects readability, consistency, and how people interpret your code. Most confusion comes from mixing C# keywords with framework type names.
They Point to the Same Type
string is a C# keyword. String is the framework type name, short for System.String. The compiler treats them as the same type.
You can prove that directly:
Both lines print True.
That means there is no performance difference, memory difference, or feature difference between string and String. If you declare a variable with either spelling, the runtime type is still System.String.
Why C# Has Both Spellings
C# includes keyword aliases for several built-in framework types:
- '
intforSystem.Int32' - '
boolforSystem.Boolean' - '
objectforSystem.Object' - '
stringforSystem.String'
The aliases make code look like a language rather than a library lookup. That is why idiomatic C# typically uses string in variable declarations, method parameters, and return types.
The same code can be written with String, but most C# style guides would consider that less natural:
Both compile to the same thing. The difference is style.
When String Still Appears Often
You still see String in a few places.
One is when reading .NET documentation, because the framework type is documented as System.String. Another is when calling static members, where some developers prefer the type name:
Both calls are valid because static members are available through either name. Many teams still prefer string.IsNullOrWhiteSpace for consistency with the keyword alias.
You may also see String when code is auto-generated, translated from another .NET language, or written by developers who want to emphasize the framework type explicitly.
What the Style Guidance Usually Is
The usual C# convention is simple:
- use
stringin declarations and ordinary code - use framework type names like
StringBuilder,DateTime, orCultureInfowhen no keyword alias exists - stay consistent within the codebase
That convention matches the wider pattern of using int, bool, and string rather than Int32, Boolean, and String.
Consistency matters more than dogma. A codebase that mixes both spellings randomly is harder to scan than one that follows a clear rule.
Related Detail: string Is Immutable
A separate but important fact is that System.String is immutable. That property is true no matter which spelling you use.
This prints cats and then cat because concatenation creates a new string object instead of modifying the old one.
People sometimes assume String and string differ because String looks like a class name and string looks like a primitive. In C#, string is still a reference type, and it still has all the behavior of System.String.
Common Pitfalls
A common mistake is thinking string is a lightweight primitive while String is a heavier object wrapper. That is false in C#. They are the same type.
Another mistake is mixing String and string arbitrarily in the same file. The code still works, but it creates visual noise and makes style look accidental.
Some developers also assume string cannot access static members because it is a keyword. It can. string.IsNullOrEmpty is just as valid as String.IsNullOrEmpty.
Finally, do not confuse this topic with nullable reference types. string versus string? is a separate question about nullability annotations, not about string versus String.
Summary
- '
stringis the C# keyword alias forSystem.String.' - '
Stringandstringcompile to the same runtime type.' - There is no performance or behavior difference between them.
- Most C# code uses
stringfor declarations because it is the idiomatic style. - The real rule is consistency: pick the convention your codebase follows and use it uniformly.
Related reading
- What 'additional configuration' is necessary to reference a .NET 2.0 mixed mode assembly in a .NET 4.0 project?
- What are attributes in .NET?
- What are Automatic Properties in C and what is their purpose?
- What are 'closures' in .NET?
- What are difference between using Invoke and SynchronizationContext.Post object?
- What are differences between AssemblyVersion, AssemblyFileVersion and AssemblyInformationalVersion?
- What are major differences between C and Java?
- What are major differences between C and Java?

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.