I wish the compiler/editor would fix this stuff for us (with our
confirmation). Sure, it won't catch/fix everything, but instead of simply
reporting a compile error, it could for example list the errors as it
currently does, but also have a small QuickFix button for each entry it can
guess at a fix. If a QuickFix button fixes the last error, start a
re-compile. For example, the compiler could easily figure the one below out
and suggest adding an "m". Also the line "a = b" is almost certainly
missing a semicolon so make that the option. It could even suggest changing
"sw.WriteLn" to "sw.WriteLine" etc. Agreed it won't always be correct (then
don't click the error's quickfix button), but it would be a great addition
(IMHO).
Hilton
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:11**********************@e9g2000prf.googlegro ups.com...
On Oct 25, 8:12 am, "Kuldeep" <kuldeep.vijayku...@hotmail.comwrote:
>Hi All,
I have this piece of code shown below:
decimal ft = Convert.ToDecimal(txtft.Text);
decimal inch = Convert.ToDecimal(txtin.Text);
decimal metre = ((ft * 12) + inch) * 0.0254;
When I run this, I get the follwing error:
Error 1 Operator '*' cannot be applied to operands of type 'decimal' and
'double'
How do I get this done?
Multiply by decimals instead:
decimal metre = ((ft * 12) + inch) * 0.0254m;
Note the "m" at the end of 0.0254 to force the literal to be a decimal
instead of a double.
Jon