How do I check if a number is positive or negative in C#?
Solution 1:
bool positive = number > 0;
bool negative = number < 0;
Solution 2:
Of course no-one's actually given the correct answer,
num != 0 // num is positive *or* negative!
bool positive = number > 0;
bool negative = number < 0;
Of course no-one's actually given the correct answer,
num != 0 // num is positive *or* negative!