I have a very quick question about the best way to use two variables. Essentially I have an enum and an int, the value for which I want to get within several ifs. Should I declare them outside the if's or inside - consider the following examples:
e.g.a:
public void test() {
    EnumName? value = null;
    int distance = 0;
     if(anotherValue == something) {
        distance = 10;
        value = getValue(distance);
     }
     else if(anotherValue == somethingElse) {
        distance = 20;
        value = getValue(distance);
     }
    if (value == theValueWeWant){
      //Do something
 }
OR
e.g.2
public void test() {
     if(anotherValue == something) {
        int distance = 10;
        EnumType value = getValue(distance);
        if (value == theValueWeWant){
           //Do something
     }
     else if(anotherValue == somethingElse) {
        int distance = 20;
        EnumType value = getValue(distance);
        if (value == theValueWeWant){
            //Do something
     }
 }
I am just curious which is best? or if there is a better way?
 
     
     
     
    