// Decrement the selected choice index public void DecrementSelection() { int newIndex = SelectedChoiceIndex - 1; // Make sure the decrement is not less than 0 if (newIndex < 0) { // Make the index wrap back around to the array's maximum index SelectedChoiceIndex = Choices.GetUpperBound(0); } else { // The proposed index is not less than 0; decrement the index SelectedChoiceIndex = newIndex; } }
/* INCREMENT/DECREMENT METHODS */ // Increment the selected choice index public void IncrementSelection() { // Make sure that we're not going out of bounds, and if we are, loop back to index 0 int newIndex = SelectedChoiceIndex + 1; // If the new proposed index is more than the last index in the Choices array if (newIndex > Choices.GetUpperBound(0)) { // Set the selected choice index to 0 SelectedChoiceIndex = 0; } else { // The proposed index is not more than the last index in the choices array, set it to the propsed index SelectedChoiceIndex = newIndex; } }