Problem with array

I got this weird bug that is keeping me awake right now, and I can’t seem to get it fixed,
sometimes it displays all of them filled in, but sometimes it leaves gaps like you can see…

Here’s the code:

    static string[] cards = new string[52]; //all indexes already assigned
    static string[] AI1cards = new string[13]; // 13 cards for AI 1
    static Random rand = new Random();
    static List<int> uniqueNumber = new List<int>();

            for (int i = 0; i < AI1cards.Length; i++)
            {
                int number = rand.Next(0, 51);
                while (uniqueNumber.Contains(number))
                {
                    number = rand.Next(0, 51);
                }
                uniqueNumber.Add(number);
                AI1cards *= cards[number];*

}
//Print on console
for (int i = 0; i < AI1cards.Length; i++)
{
Console.WriteLine("AI1 Card " +i+ ": " + AI1cards*);*
}
Console prints: (always random but leaves gaps sometimes for some reason)
AI1 Card 0: Heart 5
AI1 Card 1:
AI1 Card 2: Diamonds 4
AI1 Card 3: Heart J
AI1 Card 4:
AI1 Card 5: Diamonds J
AI1 Card 6: Heart 8
AI1 Card 7: Clubs 5
AI1 Card 8: Diamonds 6
AI1 Card 9: Clubs 9
AI1 Card 10: Heart 2
AI1 Card 11: Clubs 4
AI1 Card 12: Heart 10

using UnityEngine;
using System.Collections.Generic;

public class ShadyTest : MonoBehaviour
{
    public int NumberOfPlayerCards = 13;

    private string[] _cards;
    private string[] _playerCards;

    private readonly string[] _suits = new[] { "Spades", "Hearts", "Clubs", "Diamonds" };
    private readonly string[] _cardValues = new[] { "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King" };
    
    public void Awake()
    {
        CreateDeck();
        DrawCards();
        DisplayDrawnCards();
    }

    private void CreateDeck()
    {
        _cards = new string[(_suits.Length * _cardValues.Length)];

        for (var suit = 0; suit < _suits.Length; suit++)
        {
            for (var card = 0; card < _cardValues.Length; card++)
            {
                _cards[(suit * _cardValues.Length) + card] = _cardValues[card] + " of " + _suits[suit];
            }
        }
    }

    private void DrawCards()
    {
        _playerCards = new string[NumberOfPlayerCards];

        var uniqueNumber = new List<int>();

        for (var i = 0; i < _playerCards.Length; i++)
        {
            int card;

            while (true)
            {
                card = Random.Range(0, _cards.Length);

                if (!uniqueNumber.Contains(card))
                {
                    uniqueNumber.Add(card);
                    break;
                }
            }

            _playerCards *= _cards[card];*

}
}

private void DisplayDrawnCards()
{
for (var i = 0; i < _playerCards.Length; i++)
{
Debug.Log(“Player card [” + i + "] = " + playerCards*);
_
}*

}
}
obviously Random isn’t a great way to shuffle the cards :wink:

Apart from your bug, you code conceptually makes no sense at all! Why not have a list of cards, and shuffle them, and then “deal” (pop them from the list)? You know, like reality.