I am also a New Learner, Base on the Request, This Simple Code would detect if a Number is Even or ODD number....

// This is to Detect Odd and Even Number

bool ValidateDegreeValue; // This is to Validate that the User Enter Number Data
        double DegreeValueNum; // This Define the Length of the Number that the User can Enter
        // The below Code will notify the User if the data enter is not Numerical
        ValidateDegreeValue = double.TryParse(txtDegreeValue.Text, out DegreeValueNum);
        if (ValidateDegreeValue == false)
        {
            MessageBox.Show("Enter Valid Temperature Value", "Input Error");
            txtDegreeValue.Focus();
            return;
        }  

   if (DegreeValueNum % 2 == 0)
        {
            txtNumClass.Text = DegreeValueNum.ToString() + " Is an Even Number";
        }
        else
        {
            txtNumClass.Text = DegreeValueNum.ToString() + " Is an Odd Number";
        }

And your question is?

WaltP, I think this is just a code snippet.

jnmisa, you can remove the use of the bool "ValidateDegreeValue" and put the TryParse iside the "if" statement if you want.

Obviously. But why?

I don't have a Question concern that... I put it there that it might help someone like me

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.