dimanche 22 mars 2020

C# WPF shorten multiple if with similar statements and condition

Is there anyway to shorten this:

private void ChangeAllBValue()
{
   if(CheckboxA1){B1 = true};
   if(CheckboxA2){B2 = true};
   if(CheckboxA3){B3= true};
   ...
   if(CheckboxA20){B20= true};
}

The program must go through all B1, B2, B3... so else-if and switch-case is unusable.

Aucun commentaire:

Enregistrer un commentaire