title: How to take 'snapshot' of variable value before a for loop? C#
body: <pre><code>     static void Main(string[] args)
      {
          Random rnd = new Random();
  
          float  myfloat = rnd.Next(1, 50);
  
          for (int i = 0; i &lt;= 2; i++)
          {
              myfloat = 3;
          }
          Console.WriteLine(myfloat);
          Console.ReadLine();
      }
  </code></pre>
  <p>Say I want to change the value of a variable for the duration of a for loop, but then I want it to go back to whatever it was just befoe the loop (if i don't know what that value was). How would I do something like that?</p>
  <p>With this code 'myfloat' is stuck at 3 after the loop ends.</p>