title: find all possible dominoes chains using recursion
body: <p>I need to find all possibilities for linear chains of dominoes tiles.</p>
  
  <p>Example:</p>
  
  <pre><code>Tiles : [3/4] [5/6] [1/4] [1/6]    
  Possible chain : [3/4]-[4/1]-[1/6]-[6/5]
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/48206913/find-all-possible-dominoes-chains-with-recursion-and-backtracking">Here</a> I found an example written in Java language. I am newbie, so I am asking for help to translate Java code to c#. I know languages are very similar.</p>
  
  <pre><code>private static void listChains(List&lt;Domino&gt; chain, List&lt;Domino&gt; list)
  {
      for (int i = 0; i &lt; list.Count; ++i)
      {
          Domino dom = list[i];
          if (canAppend(dom, chain))
          {
              chain.Add(dom);
              Console.WriteLine(chain);
              Domino saved = list.RemoveAt(i);
              listChains(chain, list);
              list.Add(new Domino(i, saved));
              chain.Remove(chain.Count() - 1);
          }
          dom = dom.flipped();
          if (canAppend(dom, chain))
          {
              chain.Add(dom);
              Console.WriteLine(chain);
              Domino saved = list.RemoveAt(i);
              listChains(chain, list);
              list.Add(new Domino(i, saved));
              chain.RemoveAt(chain.Count() - 1);
          }
      }
  }
  </code></pre>
  
  <blockquote>
    <p>Severity  Code    Description Project File    Line    Suppression State<br>
    Error   CS1503  Argument 2: cannot convert from 'ConsoleApp2.Domino' to 'int'       23  Active<br>
    Error   CS0029  Cannot implicitly convert type 'void' to 'ConsoleApp2.Domino'       21  Active<br>
    Error   CS1503  Argument 1: cannot convert from 'int' to 'ConsoleApp2.Domino'       24  Active<br>
    Error   CS0029  Cannot implicitly convert type 'void' to 'ConsoleApp2.Domino'       31  Active<br>
    Error   CS1503  Argument 2: cannot convert from 'ConsoleApp2.Domino' to 'int'       33  Active<br>
    Error   CS1061  'int' does not contain a definition for 'b' and no accessible extension method 'b' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)        42  Active<br></p>
  </blockquote>
  
  <pre><code>Domino saved = list.RemoveAt(i); list.Add(new Domino(i, saved));
  chain.Remove(chain.Count() - 1); Domino saved = list.RemoveAt(i);
  list.Add(new Domino(i, saved));
  </code></pre>
  
  <p>And I am not sure what this method does:(and how to translate to c#)</p>
  
  <pre><code>private static boolean canAppend(Domino dom, List&lt;Domino&gt; to) {
      return to.isEmpty() || to.get(to.size()-1).b == dom.a;
  }
  </code></pre>