Difference between String and string in c#?

 Posted by Sathya4260 on 1/30/2011 | Category: C# Interview questions | Views: 35064 | Points: 40

1.String is an class(System.String)
2.String is an Reference type(class)

1.string is an alias name of String class that is created by microsoft
2.string is an value type(data type)
3.string is a C# keyword
4.string is a compiler shortcut for System.String class

As per above points when we use string keyword, it reaches the System.String class and then process accordingly, So we can say that both String and string are same.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Sjena on: 8/26/2012 | Points: 10
Hi Sathya,

You have mentioned string as value type.Actually its a reference type .
There is a good description about string in the below msdn link.

Posted by: Tomicrow on: 5/18/2014 | Points: 10
According to C# language specification, as a matter of style the keyword 'string' is preferred over the full system type name System.String, so there is no difference and either can be used.



Login to post response