I have this programming problem, I’m using C#. I want to check if varA is less than 8 then execute the code which decreases the value, like this
//intial
float varA = 0.0f;
if(varA <= 8.0f){
varA -= 2.0f;
}
This code works fine, but the problem is that if varA is less than 8 then I want it to increase up it to 8 first then start decreasing.
For instance, if the varA equals 6 then it should be increased to 8 and then start decreasing. Hopefully you have got what I mean. Thanks.
You need a flag to tell you when to start running your subtraction code.
of course, the main problem above is what happens if varA is 9.0. In this case, it will not decrease but that may or may not matter to you.