I have an issue with my if else statement to where it will only display the else output and not the if output.
default:
if (GradeVar >= 10) {
Console.WriteLine("That grade is a perfect score. Well done!");
} else {
Console.WriteLine("That grade is not passing.");
}
break;
Here's the specific code I am talking about; its for a program to display certain messages for grades.
GradeVar
is always less than or equal to 9
.
However, we need a minimal, but complete and verifiable example in order to truly understand what is going wrong. So far we can tell that you're most likely in a switch
structure, and probably inside either a method
or a loop
in which GradeVar
is a parameter, local variable, or property. It would be a good idea to revise your question and include the following:
GradeVar
is declared.GradeVar
's value is modified, prior to the location in code you've already supplied.GradeVar
.I hope this helps you get the answer you need, and wish you the best of luck in your endeavors.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.