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)

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.