0

Im trying to assign a decimal value of 1 to a variable if a check box is checked but I having trouble getting it to work. Here is my code:
decimal nitrodsgn;
decimal lnitro;
decimal unitro;
if (nitrogenLowerCheckBox.Checked)
lnitro = 1;
if (nitrogenUpperCheckBox.Checked)
unitro = 1;
nitrodsgn = (lnitro + unitro)

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by sknake
1

To assign a decimal like that at compile time you need to use a suffix to instruct the compiler what data type to use.

decimal d = 1.0m;
float f = 1.0f;

The default for non-integral numbers is double.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.