Difference between string and String in C#

In this article, we will learn about what is the difference between string and String in C#.

In C#, string is an alias for the String class in .NET.

In fact, every C# type has an equivalent in .NET. As another example, short and int in C# map to Int16 and Int32  in .NET.

In C#, string is a class. Both string and String class comes from the System.String class.

The small difference between string and String is, to use String class, we need to import the System namespace on top of our file. For string keyword, we don’t have to do this.

That is, “Many developers prefer to declare a string variable with string but use the String class when accessing one of its static members”

So, technically there is no difference between string and String.


using System;
namespace ConsoleApp1
    class Program
        static void Main(string[] args)
            string firstName = "Joseph";
            string lastName = "Prince";
            string fullName = String.Concat(firstName, lastName);

If you like this article, please subscribe my blog to get C#, Angular, Programming, Web Development tutorials at your inbox

0 thoughts on “Difference between string and String in C#”

  1. Hello,

    There is actually a difference from a maintenance point of view, though unlikely, one can create a “String” class and use that, whereas the “string” keyword always ensures that the system string is being used.

    Vlad V.

Leave a Comment

Your email address will not be published. Required fields are marked *