title: Using variable value as for loop index
body: <p>I have a code which contains 2 for loops:</p>
  
  <pre><code>for (int count = 0; list_Level[count] &lt; list_Level[list_Level.Count]; count++)
  
          {
              for (int a = 0; list_Level[a] &lt; Initial_Lvl; a++)
              {
                  var dOpt = new DataGridObjectOpt();
  
  
                  double Closest_Goallvl = list_Level.Aggregate((x, y) =&gt; Math.Abs(x - Initial_Lvl) &lt; Math.Abs(y - Initial_Lvl) ? x : y);
  
                  dOpt.ImageSource = new Uri(filePaths[a], UriKind.RelativeOrAbsolute);
  
                  dOpt.Level_Index = Initial_Lvl;
                  dOpt.Level_Goal = goallvl;
                  dOpt.Stage = 1;
  
                  LOpt_Temp.Add(dOpt);
  
              }
  
              count = a;
              int best_Profit_Ind = LOpt_Temp.FindIndex(x =&gt; x.TotalCost == LOpt_Temp.Max(y =&gt; y.TotalCost));
              LOpt.Add(LOpt_Temp[best_Profit_Ind]);
              dataGridOpt.ItemsSource = LOpt;
          }
  </code></pre>
  
  <p>I want the loops to begin at 0, however once the inner loop ends for the first time and ends at a value of <code>a</code>, i want the outer loop to begin from this place now.</p>
  
  <p>For example, first loop begins at 0, inner loop exits when a=6. Now i want count to start for 6 and not 1.</p>
  
  <p>Thank you.</p>