15

Possible Duplicate:
In C# what is the difference between String and string

In C# there is string and there is System.String.

What is the difference between these? Is one considered better to use that the other. Are there any hidden dangers in mixing the use of them?

If they are the same, then why have them both? Why not just have one or the other?

Community
  • 1
  • 1
Vaccano
  • 78,325
  • 149
  • 468
  • 850
  • 3
    This is a duplicate many times over. Please see http://www.google.com/search?q=difference+string+vs+string+site%3AStackoverflow.com&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a – Andrew Hare Feb 11 '10 at 00:01
  • I did not realize it was such a duplicate. Sorry for not searching better. – Vaccano Feb 11 '10 at 00:04

4 Answers4

8

System.String is the name of the actual .NET CLR class, just like System.Int32 is the real name of that class. But the designers of C# wanted it to look a lot like C and C++, where the native types (like int) are in lower case, so they added aliases for the basic native types.

Jay Bazuzi
  • 45,157
  • 15
  • 111
  • 168
James Curran
  • 101,701
  • 37
  • 181
  • 258
6

There is no difference.

http://msdn.microsoft.com/en-us/library/362314fe.aspx

The string type represents a sequence of zero or more Unicode characters. string is an alias for String in the .NET Framework.

Cory Charlton
  • 8,868
  • 4
  • 48
  • 68
4

No difference string is an alias for String. See here

For more information, see the following sections in the C# Language Specification:

2.4.2 Identifiers

2.4.4.5 String literals

4.2.3 The string type

7.9.7 String equality operators

Sam Holder
  • 32,535
  • 13
  • 101
  • 181
3

string is just an alias for System.String

joejoeson
  • 1,107
  • 1
  • 10
  • 14