Why do lowercase and uppercase versions of string exist and which should I use? [duplicate]

Solution 1:

In C#, lower-case type names are aliases for the System.xxx type names, e.g. string equals System.String and int equals System.Int32.

It's best practice to use these language aliases for the type names instead of their framework equivalent, for the sake of consistency. So you're doing it wrong. ;-)

As for a reason why they both exist, the .NET types exist because they are defined in a language-independent standard for the .NET libraries called CTS (common type system). Why C# defines these aliases is beyond me (VB does something quite similar). I guess the two reasons are

  1. Habit. Get all these C and Java programmers to use C# by providing the same type names for some fundamental types.
  2. Laziness: You don't have to import the System namespace to use them.

EDIT Since many people seem to prefer the other notation let me point out that this is by no means unreasonable. A good case can actually be made for the usage of the CTS type names rather than C#'s keywords and some superficially good arguments are offered in the other answers. From a purity/style point of view I would probably concur.

However, consider if this is worth breaking a well-established convention that helps to unify code across projects.

Solution 2:

It is conceptually similar to something like this:

using int=System.Int32

Solution 3:

string is mapped to the String class AFAIK, so they're the same.

The same is true for, for example int and Int32.