Avatar of sneeri_c
 asked on

C# Do / While Statement

I am trying to write a Do Statement that will loop until 1 of 2 variables meets the criteria of the while statement. So when either intWidth or intHeight drops below either MaxWidth or MaxHeight respectively the loop will end.

Right now when I run this, the loop continues until both intWidth and intHeight are below MaxWidth and MaxHeight.

                    intHeight = (int)Math.Round(MaxHeight * varRatio, 0);
                    intWidth = (int)Math.Round(MaxWidth * varRatio, 0);
                } while (intWidth > MaxWidth || intHeight > MaxHeight);

Any help would be great



Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Gregory is right.

|| is an OR operator. If one of the variables meets the criteria of the statement, the loop will continue.
&& is an AND operator. The loop will continue as long as both of the variables meet the criteria. If one of both variables drops below the MaxWidth or MaxHeight, the criteria is no longer met and the loop will end.
Your help has saved me hundreds of hours of internet surfing.