Eine etwas gedrechselte Version wäre
public static bool AnyNegative(int[] arr){
const long firstBit = 2147483648;
var res = false;
for (var i = 0; i < arr.Length && !res; i++) res = (arr[i] & firstBit) == firstBit;
return res;
}
Sie können es wie folgt aufrufen>
int arr = {...}
if(arr.AnyNegative()){
//do stuf if there's any negative numbers
}
Natürlich ist dies nur eine verschleierte Version von
public static bool AnyNegative(int[] arr){
var res = false;
for (var i = 0; i < arr.Length && !res; i++) res = arr[i] < 0;
return res;
}