C# false if statement being used -


solved: code excecuted via events every 10 ms, increasing time takes between events solved issue.

i´m experiencing odd indexoutofrangeexception shouldn´t happening. code inside if statement being used though statement ´false´. known problem? if so, how can fix this?

the error occurs when counter (an int) 0, requesting element -1 array lights.

code:

 if (counter  > 0)     {     console.writeline("counter-1 groter dan 0");     int = counter - 1;     lights[i].setstate(0);     } 

unless counter accessed/manipulated in multi-threaded way - should impossible state.

you can try making assignment & check in 1 place:

 var index = 0;   if ((index = (counter - 1))  > 0)  {     lights[index].setstate(0);  } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -