mercredi 3 juin 2015

C# change if statement from variable

Not sure if the question is correct, but here is what I am trying to accomplish.

I am running a for-loop in which i want to change the if-statement in each loop.

Here is the example:

for(int i=0;i<3;i++){

    int currentField = field;

    var context1=currentField;
    int curprogr=0;

    switch (i){
    case 0:
        context1 = currentField % 10 != 0;
        curprogr = 1;
        break;
    case 1:
        context1 = Mathf.Floor(currentField/10) != 0;
        curprogr = 10;
        break;
    case 2:
        context1 = currentField % 10 != 0 && Mathf.Floor(currentField/10) != 0;
        curprogr = 11;
        break;
    }

    while(context1){ // Here is where I want it to chnage for each time the loop runs through //
        // Some logic here... //
    }
}

I get this error: Cannot implicitly convert type bool' toint' in every switchcase in regards to the context1.

Hope this makes sense and any help is appreciated.

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire