Best practice and memory performance?

If I have a temp game object or list or anything in a function would it be best practice to call it each time I call the function or should I just have a temp global variable that assigns a new value?

     private int bar = 0;
     private void Foo(int value)
     {
        bar = value;
     }

Or

      private void Foo(int value)
      {
         int bar = value;
      }

Variables should always be defined as locally as possible. In your code “bar” is a value type allocated on the stack, so deallocating it generates no work for the garbage collector, and there is no reason to persist it outside the scope of the Foo() function.