Back to results for “Objects”
C# Programming › Strings in C#

What is the difference between string keyword and System.String class?

Beginner

Answer

The string keyword in C# is simply an alias for the System.String class provided by the language for convenience, meaning both refer to exactly the same type and can be used interchangeably. There is no functional difference between them, but developers commonly use the lowercase string keyword for everyday coding and reserve System.String for situations like reflection or when being explicit about the full type name.
string name1 = "Ali";
System.String name2 = "Ali";
// Both lines create the exact same type
Real-world example A code style guide at a company recommends always using the lowercase string keyword instead of System.String, purely for consistency and readability, since both compile to the exact same underlying type.

Common follow-ups: Are there other C# keywords that alias BCL types the same way string aliases System.String?;Does using string instead of System.String affect performance in any way?