Question

Hello and please forgive the noob question.

I can for example EXPLICITLY define a variable using 'var' to be, for example, a DOUBLE type:

var num = 5d;

I know I know, I'm really obfuscating the fact that 'var' implies implicit! But really feel that there is an explicitness in defining the variable with the 'd', because as you are most likely aware, without the 'd', you are leaving it up to the compiler, hence to me a more implicit initialization.

This instead will define an Int32, and really, as you didn't make a choice (or maybe you were really smart and knew what the default would be - but the default might change in the future so be careful!),

var num = 5;

To my noob question however... Am trying to find a chart showing me all the available initializations.... But alas, I've forgotten "what" this type of initialization shorthand is called... :(

thank you!

Was it helpful?

Solution

If I understand you correctly, you are searching something like this: http://www.dotnetperls.com/suffix

Suffix type: unsigned int
Character:   U
Example:     uint x = 100U;

Suffix type: long
Character:   L
Example:     long x = 100L;

Suffix type: unsigned long
Character:   UL
Example:     ulong x = 100UL;

Suffix type: float
Character:   F
Example:     float x = 100F;

Suffix type: double
Character:   D
Example:     double x = 100D;

Suffix type: decimal
Character:   M
Example:     decimal x = 100M;

Of course you can also use lower case letters.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top