tags:

views:

121

answers:

2

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

I couldn't find the info anywhere, but I'm sure it's just a simple answer. Are they interchangeable??

+7  A: 

Yes, they are identical. string is just the C# name for a System.String, which you can also use. See MSDN:

The string type represents a string of Unicode characters. string is an alias for System.String in the .NET Framework.

It's personal preference, but I always use string over String. I guess I like the blue color over the, uh, turquoise color offered by the default syntax highlighting.

You can see the other aliases under the C# value types on MSDN (e.g. int is really System.Int32 while long is really System.Int64).

Chris Schmich
A: 

You get this question a lot because in java there is a difference between for example Integer and int (pointer allocation). In C# there is no difference between String and string, nor there is a difference between Int32 and int etc..

Andre Haverdings
This is wrong, as has been discussed countless times already here on StackOverflow. `string` is an alias for `System.String`, i.e. it will *always* be the framework class. `String` follows the normal lookup rules, i.e. it will use *any* class named `String` which happens to be in scope.
Jörg W Mittag
euhm.. this isn't wrong ?? any good programmer would not create their own String class (and if they must they would name it MyString or something)..And I just pointed out that in JAVA there is a difference between a primitive (int) and an object (Integer).
Andre Haverdings