title: Using Generic Functions for collision detection in C# / XNA
body: <p>I am making a physics engine in c# / XNA, I have three basic objects...</p>
  
  <p>Sphere
  Cube
  Plane</p>
  
  <p>that are all derived from </p>
  
  <p>GameObject</p>
  
  <p>I store all my objects in a list of GameObjects and I would like to loop through this list and be able to call a CheckCollision function that will go to the correct function for each pair of objects</p>
  
  <p>eg</p>
  
  <p>go is a Sphere,</p>
  
  <p>go2 is a Sphere</p>
  
  <pre><code>if(CheckCollision(go, go2))
  {
    //do stuff
  }
  
  bool CheckCollision(Sphere one, Sphere two)
  {
    //Check Sphere to Sphere
  }
  
  bool CheckCollision(Sphere sphere, Plane plane)
  {
    //Check Sphere to Plane
  }
  </code></pre>
  
  <p>and I would like it to just go to the correct function withour having to use if checks.</p>
  
  <p>Thank you.</p>