3
Reply

What is the difference between String and string ?

Athar Ali

Athar Ali

16y
8k
0
Reply

    string is keyword(blue color) string s = "C-SharpCorner.com"; Console.WriteLine(s); output: C-SharpCorner.com String is Class(Green color) String s = new String('A',5); Console.WriteLine(s); output: AAAAA prints the character 5 times

    Both are premitive data type but 'string' is for C# and 'String' for .net framework

    There's no difference.

    The C# type 'string' is just an alias for the .NET type 'System.String'.

    So, as long as you include the following using directive in your program:

        using System;

    then 'string' and 'String' can be used interchangeably.