Difference between String and string in c#?

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

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

string:
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.

http://msdn.microsoft.com/en-us/library/362314fe.aspx
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.

More...http://net-informations.com/q/faq/stringstring.html

Tomi

Login to post response