-3

I'm training C# on a simple card game. I have methods that shuffle and deals the cards. I have a random deck that is well generated. Is it possible to set an array for the player1 cards, picking up the first ten values of the array. Here is a part of my code :

currentCard = 0;
    public Card DealCard()
    {
        if (currentCard < deck.Length)
            return deck[currentCard++];
        else
            return null;
    }

I want to pick up for example ten first values of

deck[currentCard++]

Any suggestions will be appreciated, thanks for your help !

Julien
  • 25
  • 1
  • 7
  • What do you mean by "pick up"? – Lasse V. Karlsen Aug 22 '17 at 10:37
  • Well thank you guys for downvotes but it's not what I'm looking for, post is solved thanks – Julien Aug 22 '17 at 10:44
  • Downvotes can indicate lack of *demonstrated* research (i.e. in this particular case there are hundreds questions about slicing and dicing arrays in all possible ways) as well as clarity of the question (which this post somewhat lacking as it is not clear what exactly you don't understand - i.e. suggested `.Take(10)` answer *should* be over your head based on this question, but somehow it is very clear for you as you've accepted that answer). – Alexei Levenkov Aug 23 '17 at 06:37
  • Side note: please check out https://meta.stackoverflow.com/search?q=remove+fluff discussions before adding "thanks" to your next post. – Alexei Levenkov Aug 23 '17 at 06:38

1 Answers1

2

You mean you want to pull the first 10 enties into another array? Something like;

var player1Cards = deck.Take(10);

or

List<int> player1Cards = new List<int>();
for (int i = 0; i < 10; i++){
    player1Cards.Add(deck[i]);
}
Milney
  • 6,253
  • 2
  • 19
  • 33