I've chosen a struct for each playing card; there's little in the way of code apart from the overridden ToString() method. This uses a static bool ShortCard to output the cards in either long format E.g. King Spades or short, e.g. KS. This is a public static field in the CardType struct. Being static, it affects every card.
CardType.ShortCard = false; // false = long formatEnums are used for both the card values and suits. The Deck class holds an array of 52 cards and these are created by an initializer. A double loop then initializes the deck of cards. You can verify this by commenting out the ShuffleDeck() call and the cards will be printed in order. Two for loops would have done but this gave a chance to use the foreach construct. This iterates through all members of the CardSuit and CardValue enums.
int index=0;The first foreach is the same as
foreach (CardSuit Suit in Enum.GetValues(typeof(CardSuit)))
{
foreach (CardValue Value in Enum.GetValues(typeof(CardValue)))
{
cards[index].Value = Value;
cards[index].Suit = Suit;
index++;
}
}
for (CardSuit Suit = CardSuit.Hearts;Suit < CardSuit.Spades;Suit++)But the foreach is all round better- you're not going to pick the wrong value in the For loop as I did. Hearts was the first enum value, but the Intellisense feature of the IDE kept displayed the available values in alphabetical order.
On the next page Using an Indexer

