public static bool IsStraight(Card[] hand) { // Sort hand by rank. hand = hand.OrderBy(item => Enumeration.FindByName <Rank>(item.Rank).Id).ToArray(); // Increments the rank of the current position by 1, beginning the sequence. int sequentialRank = Enumeration.FindByName <Rank>(hand[0].Rank).Id + 1; // If the next card does not match the sequence, the loop breaks. Otherwise, it succeeds. for (int i = 1; i < hand.Length; i++) { if (hand[i].Rank != Enumeration.FindById <Rank>(sequentialRank++).Name) { return(false); } } return(true); }