8
I have an array, say
int[] array = new int[] { 1, 5, 11, 5 };
How can I check (in the most easy and efficient way) that all elements are positive? If at least one number is not a positive integer, the system will respond in a negative way.
Desired output:
if all the numbers are positive, then it will display "All Positive" else "Wrong"
My shot
int[] array = new int[] { 1, 5, 11, 5 };
var x = array.All(c => c >= '0' && c <= '9');
if (x == true) "Positive" else "Wrong";