How to code card seperating

Hi How to C sharp Code for 52 cards should randomly divide by to and 26 card should one side and another 26 card other side please healp me

If your deck is a List of Card gameObjects and your two subdecks are as well, you can grab a random card from that list, add it to the first subdeck.

Repeat this using a loop until you’ve done it for half your deck size.

            int halfDeckSize = deck.Count / 2;

            while (deck.Count > halfDeckSize)
            {
                int nextCard = Random.Range(0, deck.Count);
                subDeck1Cards.Add(deck[nextCard]);
                deck.Remove(deck[nextCard]);
            }

Then do a similar loop to shuffle the remaining cards into the second subdeck.

            while (deck.Count > 0)
            {
                int nextCard = Random.Range(0, deck.Count);
                subDeck2Cards.Add(deck[nextCard]);
                deck.Remove(deck[nextCard]);
            }

This should end you up with two shuffled half-decks.