编辑代码

using System;
using System.Collections.Generic;

public class DeckOfCards
{
    private List<string> deck;

    public DeckOfCards()
        {
            deck = new List<string>();
            InitializeDeck();
        }

private void InitializeDeck()
    {
    string[] suits = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" };
    string[] values = { "A", "B", "C", "D"};

    foreach (string suit in suits)
        {
            foreach (string value in values)
            {
                deck.Add(suit + " of " + value);
            }
        }
}

public void Shuffle()
{
    Random rng = new Random();
    int n = deck.Count;
    while (n > 1)
    {
        n--;
        int k = rng.Next(n + 1);
        string value = deck[k];
        deck[k] = deck[n];
        deck[n] = value;
    }
}

public void DisplayDeck()
{
    foreach (string card in deck)
    {
        Console.WriteLine(card);
    }
}
}

class Program
{
    static void Main(string[] args)
    {
        DeckOfCards deck = new DeckOfCards();
        Console.WriteLine("Deck before shuffling:");
        deck.DisplayDeck();
        Console.WriteLine("\nShuffling deck...");
        deck.Shuffle();
        Console.WriteLine("\nDeck after shuffling:");
        deck.DisplayDeck();
    }
}