title: c# Poker Cards Combinations
body: <p>Hy, I want to count of all combinations of poker cards that player can get in one hand and to display all that combinations. I don't care about how many pairs, full houses etc. are there. I just want to count all possible hands that player can get. So, one hand is made of 5 cards, there must be 4 colors (suits) and one suit must repeat. Maximum is that 4 numbers are same, number of 5th card must be different. Correct result of all possible hand combinations must be 2598960 (52 above 5 is 2598960). I just need to get correct result using my code, but I don't know how to write algorithm.<br>
  I have <code>card</code>.cs class:  </p>
  
  <pre><code>class card
  {
      private int number;
      private char suit;
  
      public card(int _number, char _suit)
      {
          this.number = _number;
          this.suit = _suit;
      }
  
      public int Number
      {
          get{return this.number;}
          set{this.number = value;}
      }
  
      public char Suit
      {
          get { return this.suit; }
          set { this.suit = value; }
      }
  
  }
  </code></pre>
  
  <p>and in <code>Program</code>.cs class, I have Main and this code:</p>
  
  <pre><code>static void Main(string[] args)
      {
          char[] suits = { '\u2660', '\u2663', '\u2665', '\u2666' }; //Spades, Clubs, Hearts, Diamonds
          int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
          int cnt = 0;
  
          List&lt;card&gt; deck = new List&lt;card&gt;();
  
          //making deck
          foreach (char suit in suits)
          {
              foreach (int number in numbers)
              {
                  deck.Add(new card(number, suit));
              }
          }
  
          foreach (card first in deck)
          {
              foreach (card second in deck)
              {
                  if (second.Number != first.Number)
                  {
                      foreach (card third in deck)
                      {
                          if (third.Number != second.Number &amp;&amp; third.Number != first.Number)
                          {
                              foreach (card fourth in deck)
                              {
                                  if (fourth.Number != third.Number &amp;&amp; fourth.Number != second.Number &amp;&amp; fourth.Number != first.Number)
                                  {
                                      foreach (card fifth in deck)
                                      {
                                          if (fifth.Suit != first.Suit &amp;&amp; fifth.Suit != second.Suit &amp;&amp; fifth.Suit != third.Suit &amp;&amp; fifth.Suit != fourth.Suit)
                                          {
                                              //Console.WriteLine("{0}{1}   {2}{3}     {4}{5}   {6}{7}    {8}{9}", first.Number, first.Suit, second.Number, second.Suit, third.Number, third.Suit, fourth.Number, fourth.Suit, fifth.Number, fifth.Suit);
                                              cnt++;
                                          }
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
          }
          Console.WriteLine("Combinations: {0}", cnt);//Result must be: 2598960
      }
  </code></pre>