Home > Tutorial for Beginners > Difference – string and String. How to decide which one should be used?

Difference – string and String. How to decide which one should be used?

The main points of difference b/w string and String are—
1) String is just an alias for String in the .NET Framework. So the following line of code has no error-
string str = new String();

2) where String is a class, string is just a keyword.

3) you can use string without a “using System;” directive, while String requires it.

4) Instance methods of the class can not be called by string but can be called by String.
Their is no such difference between string and String, actually it let the user who is coming from C/C++ background and to make Understand that familiar data types names available in C# as it is available in c/c++.

 

Read Part 1: Tutorial on Strings in C#

Read Part 2: String Manipulation Functions in C#

 

 

 

Post Comments Below