4

Possible Duplicate:
String vs string in C#

What is the difference Between String and string or Double and double?

if i use :

double s1; or

if i use Double s1;

can you give pros and cons?

Community
  • 1
  • 1
Penguen
  • 16,836
  • 42
  • 130
  • 205

4 Answers4

11

string is just the C# alias for the System.String class. The same is true for all the other built-in language types like:

  • int (System.Int32)
  • float (System.Single)
  • double (System.Double)
  • decimal (System.Decimal)
  • bool (System.Boolean)
  • and so on...

As far as usage conventions go, I completely agree with this answer on SO.

Related resources:

Community
  • 1
  • 1
Enrico Campidoglio
  • 56,676
  • 12
  • 126
  • 154
4

string is an alias for System.String. It doesn't matter whether you use String or string. It's in the end translated into System.String anyway.

It's the same case as with System.Int32 and int etc.

Here is the list of all aliases.

Ondrej Slinták
  • 31,386
  • 20
  • 94
  • 126
2

See : string (Référence C#)

According to MSDN :

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

In short, no difference, as one is a sugar syntax for the other.

Will Marcouiller
  • 23,773
  • 22
  • 96
  • 162
2

string or String is CLR aliases for System.String