;

Difference between string and String in C#


Tutorialsrack 20/02/2019 C#

In this article, we discuss "What is the difference between string and String in C#?".

In C#,  string is an alias for the String class in .NET framework. Anything you can do with System.String, you can also do with string. Both are derived from System.String. So, technically both of these are the same but with a slight difference.

The slight difference between string and String

  • For using String, you need a namespace "System" while for using "string", there is no need of namespace "System".
Example
string world = "world";
string str = String.Format("Hello {0}", world);
//Output Will be "Hello World"

// Another Example

string firstname = "Sourabh";
string lastname = " Chauhan";
string fullname = String.Concat(firstname,lastname);
//Output Will Be "Sourabh Chauhan"


Related Posts



Comments

Recent Posts
Tags