title: ArgumentOutofRangeException
body: <pre><code>Random r = new Random();
          int InvadorNumberA=r.Next(0,5);
          int randomShot = r.Next(5);
  
          List&lt;Invaders&gt; invadersShooting = new List&lt;Invaders&gt;();
          Invaders invaderA=new Invaders();
  
          var invaderByLocationX = from invadersSortByLocation in invaders
                                   group invadersSortByLocation by invadersSortByLocation.Location.Y
                                   into invaderGroup
                                   orderby invaderGroup.Key
                                   select invaderGroup;
  
         invadersShooting = invaderByLocationX.Last().ToList();
  
       try
         {
  
             invaderA = invadersShooting[InvadorNumberA];// constantly being thrown there. i cant catch the exception.. so i guess it is being thrown somewhere else. any idea on how i stop it from being thrown?
  
         }
          catch(ArgumentOutOfRangeException dd)
         {
             invaderA = invadersShooting[0];
         }
  </code></pre>
  
  <p>stack Trace</p>
  
  <blockquote>
    <p>"   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)\r\n   at System.ThrowHelper.ThrowArgumentOutOfRangeException()\r\n   at System.Collections.Generic.List`1.get_Item(Int32 index)\r\n   at WindowsFormsApplication1.Game.ReturnFire() in D:\Documents and Settings\Dima\My Documents\Visual Studio 2008\Projects\SpaceInvaders\SpaceInvaders\SpaceInvadorGame\Game.cs:line 444"</p>
  </blockquote>
  
  <p>Target Site</p>
  
  <blockquote>
    <p>{Void ThrowArgumentOutOfRangeException(System.ExceptionArgument, System.ExceptionResource)}</p>
  </blockquote>
  
  <p>More info:</p>
  
  <pre><code>{"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"}
  </code></pre>
  
  <blockquote>
    <p>{"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"}</p>
  </blockquote>
  
  <p>i got rid of the exception by simply doing this</p>
  
  <pre><code> invadersShooting = invaderByLocationX.Last().ToList();
  
             invaderA = invadersShooting[r.Next(0,invadersShooting.Count)];
  </code></pre>
  
  <p>but i am still curious,,on where the exception was thrown..hmmm</p>