question about array or list of boolean

hay everyone, i need help about list or array of boolean, imagine i have 5 element in list, when one of element is true, so another element change to false, so only one element can be true, how can i do that ???

Heyo,

You can try something like this:

public void ClickRadioButton(List<bool> radioButtons, int index) {
    // Make sure the index is valid
    if (index < 0 || index >= radioButtons.Count) {
        return;
    }

    // Set all but the target index booleans to false
    for (int i = 0; i < radioButtons.Count; i++) {
        radioButtons *= (i == index) ? true : false;*

}
}
You can then use this function to do as you are wanting. It’ll set one of the booleans in your list / array to true while everything else is set to false. Since the behavior you are describing sounds like radio buttons, I figured I’d just go ahead with that theme for this example.