title: System.ArgumentOutOfRangeException: Argument is out of range. error in a shortest path algorithm
body: <p>I am trying to solve a problem. This program contains all the edge in a graph. The shortest path from source to destination is to find out. I have function named dotest as below. </p>
  
  <pre><code> public void dotest()
      {
          List&lt;edge&gt; tlist;
          Int32  x;
          setall();
          Int32 ind;
          foreach (edge e1 in alltest)
          {
              tlist = new List&lt;edge&gt;(alledge);
  
              ind = 0;
              foreach (edge e2 in tlist)
              {
                  if (e2.s == e1.s &amp;&amp; e2.d == e1.d)
                  {
                      break;
                  }
                  ind++;
  
  
              }
              tlist.RemoveAt(ind);
  
  
  
              x=shortpath(tlist, start, destination);
              if (x != -1)
                  Console.WriteLine("{0}", x);
              else
                  Console.WriteLine("Infinity");
  
          }
  
  
      }
  </code></pre>
  
  <p>Describing the above code. The code already contains list of alledge(all the edge or path). I have got series of input that contains list of edge to cut off and I have to find the shortest path of the new updated edge list. I compiled my test case and some of test case worked. But for some test case it have error message as.</p>
  
  <blockquote>
    <p>Unhandled Exception: System.ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index
    at System.Collections.Generic.List<code>1[ch_2_3_27.Solution+edge].RemoveAt (Int32 index) [0x00000] in :0 
    at ch_2_3_27.Solution.dotest () [0x00000] in :0 
    at ch_2_3_27.Solution.Main (System.String[] args) [0x00000] in :0 
    [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index
    at System.Collections.Generic.List</code>1[ch_2_3_27.Solution+edge].RemoveAt (Int32 index) [0x00000] in :0 
    at ch_2_3_27.Solution.dotest () [0x00000] in :0 
    at ch_2_3_27.Solution.Main (System.String[] args) [0x00000] in :0 </p>
  </blockquote>
  
  <p>I really cannot locate out error and I think all other parts works fine. Anybody can help??</p>
  
  <p>And Edge(edge) above is a struct with members s,d,w(source, destination, weight all Int 32)</p>