0
How to assign two conditions to an if statement?
hello, I am wondering if there is a away to assign two conditions to a single if statement. for example: I want something like this int test_score = 100; if (test_score == 100) Console.WriteLine("Perfect"); if (test_score >= 90 , test_score < 100); Console.WriteLine("Grade A"); Thanks in advance for any help
3 Answers
+ 6
Yes, there is. Use the operator && (AND) to check if both conditions are true.
Ex: if (test_score >= 90 && test_score < 100)
Console.WriteLine("Grade A");
+ 3
use && or ||
int test_score = 100;
if (test_score == 100)
Console.WriteLine("Perfect");
if (test_score >= 90 && test_score < 100);
Console.WriteLine("Grade A");
0
thank you so much!