What does it means?

  • Thread starter Thread starter ArtPedUK
  • Start date Start date
A

ArtPedUK

I'm new on C# and I would like to know what it means and
if it is necessary.

decimal[] balances = new decimal[12];

decimal ttl = 0m;

What does 0m, means is necessary for the programman
that "m", what does it means????????

Thanks for all

Arthur
 
ArtPedUK said:
I'm new on C# and I would like to know what it means and
if it is necessary.

decimal[] balances = new decimal[12];

decimal ttl = 0m;

What does 0m, means is necessary for the programman
that "m", what does it means????????

"m" shows that the literal should be interpreted as a decimal as
opposed to an integer.
 
Arthur,

In C++, which I'll assume you're familiar with, we can put
little modifiers after constants to identify the data type
of the constant (because the integer 0 and the floating
point number 0.0, while numerically equivalent, are stored
different in memory, again as I'm sure you already know).
Most languages have their own ways of representing these.
In C++, you refer to floating point constants with the
prefix f, like "float f = 0.0f", and long integers
like "long l = 2L". Visual BASIC uses modifers too, like
the % sign for integers, the & for long integers, the #
sign for double-precision floats, and the ! for single-
precision... I think that's right anyway.. a logn time
since I used VB....

Anyway, now that I've covered the erlavant background, the
answer to your question is that the "m" modifier
identifies the constant 0 as a "decimal" value, to match
the data type of the variable. I'm new to C# too, so if I
got that wrong, anyone feel free to chime in. :) I hope
that helps!

JIM
 
Back
Top