How to check in a bool array that one of those bool is true and which one is false?
but I would like to obtain as an integer the one that is true
get from an array of bool which is true and if respective integer that represents it in order
How to check in a bool array that one of those bool is true and which one is false?
but I would like to obtain as an integer the one that is true
get from an array of bool which is true and if respective integer that represents it in order
this should find the first one that is true and -1 if all are false
bool[] boolArray = {false, true, false, false, true};
int index = Array.FindIndex(boolArray, val => val.Equals(true));
Console.WriteLine(index);
Good drawing / diagram BTW! Excellent use of communication tools. I knew instantly what you wanted.
Any of the above solutions should be just fine for you.