50

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

Should I use string or String when declaring a basic string variable in c# and does it matter?

3

4 Answers 4

32

I like string because VS highlights it in dark blue (which makes it awesomer).

Sign up to request clarification or add additional context in comments.

3 Comments

Besides being funny, he is also 100% correct.
Which part is correct? Mine doesn't highlight in dark blue: studiostyl.es/schemes/wekeroad-ink
And awesomer is better...
20

It doesn't matter, though it's best to be consistent: lower-case string is an alias for String.

2 Comments

I find it weird to start a class name with lowercase character since it breaks every other platform convention..
7

The string keyword is an alias for System.String.

(The same goes for int - System.Int32 long - System.Int64 and so on)

C# doesn't have two different representations for primitives the same way that Java does. (Where an int is far different from an Integer)

In most cases it is best to use lowercase string because it is an alias to the fully qualified System.String. This way you can avoid type conflicts if there is another String type somewhere in your code.

1 Comment

You'd have to be nuts to name a custom class String. Though I guess you might just be using a library built by someone else who is nuts...
1

They both point to the same class. It doesn't matter which one you use.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.