title: Accessing a list from different class c#
body: <p>Hi I'm fairly new to c# and have been trying to access my list of cards from another class and get it to display a picture  on form but all i really need is the way to instantiate or reference or whatever the list from my deck class. How would i go about my list of cards in a different class?</p>
  
  <pre><code>namespace aGameOf21
  { 
     //adds deck class to Ideck interface
     public class Deck : IDeck
     {
        //default deck call
        public Deck()
        {
           Reset();
        }
        // creates list from the card class with get and set accessors
        public List&lt;Card&gt; Cards { get; set; }
        //resets the decks to unshuffled values default when calling class
        public void Reset()
        {
           // using a LINQ statement takes each enumerable from cards list and combines them
           Cards = Enumerable.Range(1, 4)
                             .SelectMany(s =&gt; Enumerable.Range(1, 13)
                             .Select(c =&gt; new Card()
                             {
                                Suit = (Suit)s,
                                CardNumber = (CardNumber)c
                             }))
                             .ToList();
          /* foreach(Card c in Cards)
           {   
              Console.WriteLine("Number = {0}, Suit = {1}", c.CardNumber , c.Suit);
           }*/
        }
  
        public void Shuffle()
        { 
           Cards = Cards.OrderBy(c =&gt; Guid.NewGuid())
                        .ToList();
        }
  
        public ICard TakeCard()
        {
           var card = Cards.FirstOrDefault();
           Cards.Remove(card);
           return card;
        }
  
        public IEnumerable&lt;ICard&gt; TakeCards(int numberOfCards)
        {
           var cards = Cards.Take(numberOfCards);
           var takeCards = cards as Card[] ?? cards.ToArray();
           Cards.RemoveAll(takeCards.Contains);
           return takeCards;
        }
     }
  }
  </code></pre>