title: C# Error message: Cannot Implicitly convert type
body: <p>The code below throws the following exception: </p>
  
  <blockquote>
    <p>Error 1   Cannot implicitly convert type
    'Clarity.DevTest.Exercises.ChessPosition' to
    'System.Collections.Generic.IEnumerable&lt;
    Clarity.DevTest.Exercises.ChessPosition>'. An explicit conversion
    exists (are you missing a cast?)</p>
  </blockquote>
  
  <p>Can someone explain to me whats going wrong and why it cant return the result?</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  
  namespace Clarity.DevTest.Exercises
  {
  public class Exercise1
  {
      public IEnumerable&lt;ChessPosition&gt; GetLegalMoves(ChessPosition rookToMove, ChessPosition friendlyRook, ChessPosition enemyRook1, ChessPosition enemyRook2)
      {
  
          //create array to hold positions
          ChessPosition[,] coords = new ChessPosition [8,8];
          //set the Rooks into the correct places on the array
          //eg rookToMove.X = 4, rookToMove.Y = 5, "R" would be places in 4,5
          coords[rookToMove.X, rookToMove.Y] = "R";
          coords[friendlyRook.X, friendlyRook.Y] = "F";
          coords[enemyRook1.X, enemyRook1.Y] = "1";
          coords[enemyRook2.X, enemyRook2.Y] = "2";
  
          //throw new NotImplementedException();
  
          ChessPosition result = new ChessPosition(4, 5);
          return result;
      }
  }
  
  public partial class ChessPosition
  {
      public ChessPosition(int x, int y)
      {
          //check to see if out of bounds
          if (x &lt; 1 || x &gt; 8 || y &lt; 1 || y &gt; 8)
          {
              throw new ArgumentException("x and y must be in the range 1-8");
          }
          X = x;
          Y = y;
      }
  
      public int X { get; set; }
      public int Y { get; set; }
    }
  }
  </code></pre>