How to cause args to enter an endless loop?
<p>I have a console application that uses a number of command line switches to control various methods. Each of the command line switches is handled by a switch statement that is within a for loop that iterates over each of the args. </p>

<pre><code>        for (int x = 0; x &lt; args.Length; x++)
        {
            switch (args[x])
            {
             ...
            }
         }
</code></pre>

<p>This works perfectly for my needs, however I need to add a --loop switch that causes the preceding args to be looped indefinitely based upon a timeout period specified by the --set-timeout switch.</p>

<p>The code I have so far is: </p>

<pre><code>switch (args[x])
{
   case "--set-timeout-5m":
       timeout = 300000;
       System.Threading.Thread.Sleep(timeout);
       break;

       ....

    case "--loop":
        x = 0;
        break;
 }
</code></pre>

<p>The problem is setting x does not cause the for loop to continue from the start of args. It just sits there. </p>

<p>I am expecting x to have scope as the code is within the for loop and no errors are generated in Visual Studio. I am also expecting the break statement to break the case and pass x to the for loop. </p>

<p>Can anyone explain why it does not work or perhaps post a workaround? </p>
