c# - How to get next value from List<string> -


i have problem list string. put 3 values mycollection

list<string> mycollection = new list<string>();  mycollection.add(encoding.default.getstring(data)); mycollection.add(encoding.default.getstring(data2)); mycollection.add(encoding.default.getstring(data3)); 

and have 3 values : a,b,c

but want block buttons contains values :

for (var = 0; < mycollection.count; i++)  {      if (mycollection.contains(a))     {          this.a.enabled = false;      }      else if (mycollection.contains(b))     {          this.b.enabled = false;     }      else if (mycollection.contains(c))     {          this.c.enabled = false;     } } 

after loop first button=false. loop done 3 times same try block button , question is: how block other buttons?

now in first loop run:

  this.a.enabled = false;  2nd this.a.enabled = false;   3rd this.a.enabled = false; 

but want :

1st :   this.a.enabled = false;  2nd :   this.b.enabled = false;  3rd :   this.c.enabled = false; 

you don't need loop this. use simple if statements without else.

if (mycollection.contains("a"))     this.a.enabled = false;  if (mycollection.contains("b"))     this.b.enabled = false;  if (mycollection.contains("c"))     this.c.enabled = false; 

mainly else causing problems you. if condition true, code b , c did not run. how else works.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -