1

What is the difference between double.Parse(myString) and Double.Parse(myString)? Is there a difference in performance or reasons I should use one but not the other?

KMC
  • 19,548
  • 58
  • 164
  • 253

5 Answers5

4

double is just a language alias for System.Double (a class recognized by the CLR), so it should be exactly the same.

Are you experiencing a specific problem that would indicate otherwise?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
M.Babcock
  • 18,753
  • 6
  • 54
  • 84
  • 1
    I want to clear up my understanding from the long comments, so: 'double' is a keyword (or alias) for System.Double, and my question should be, more correctly, "difference between double and System.Double". Am I right? – KMC Jan 14 '12 at 04:54
  • 2
    Your question is correct (at least the way those of us on planet earth understand it) and the answers you've received (save Ali's response) answer it correctly. In short, `double` is just something that ends up meaning `System.Double` to the compiler. They are the same thing it's just that the compiler lets you use `double` for legacy compatibility. – M.Babcock Jan 14 '12 at 04:58
  • @KMC: M.Babcock says it so well I don't need to add anything to that. – Sani Huttunen Jan 14 '12 at 05:03
  • Your suspicion was correct, so I removed the weasel-words. :-) – Cody Gray - on strike Jan 14 '12 at 17:14
2

None-what-so-ever...
double is an alias for System.Double. Nothing else.

so double.Parse is exactly the same as Double.Parse.

Sani Huttunen
  • 23,620
  • 6
  • 72
  • 79
2

Nothing; One of them (double or Double - don't remember) is an alias for the other.

The compiler takes care of it, so there's literally no difference.

There are other pairs of examples of this, too, like int/Int32 and String/string

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
1

Precisely,

The following table shows the keywords for built-in C# types, which are aliases of predefined types in the System namespace.

bool --> System.Boolean

decimal --> System.Decimal

double --> System.Double

int --> System.Int32

Complete list here.

Manish Basantani
  • 16,931
  • 22
  • 71
  • 103
0

In Simple word, Double is just alias for double, just Press F12 on Double Word to see this. In fact main type is double, but in .net Framework it's Double See msdn about double.

Lrrr
  • 4,755
  • 5
  • 41
  • 63