ok so here is what I'm trying to do.....and im probably doing it a dumb way, but this is my first attempt at any of this so I'm just happy if anything works lol.
I'm trying to make a blackjack game, and I made an array of card classes.
The problem is, I don't know where to actually create the array or how to make it public so that when I click on a button on my form, I can call my array. I declared it in main, and cant figure out how to access it in my form. Also I can't figure out how to make it public so I can call it....Any help ?
Loading
Jonathan CoxPosted Nov 7, 2009, 5:59 PM
Sam HobbsPosted Nov 7, 2009, 9:43 AM
Sam HobbsPosted Nov 7, 2009, 9:41 AM
Jorge L FernandezPosted Nov 7, 2009, 9:12 AM
The most appropiate way is to create your array of card inside your Form. May be created in the constructor of the Form after InitializeComponents() or in other moment you desire.
Card[] _GameCards = new Cards[52]; // Example of 52 cards
You may want to create a public property in such a way you may say "I want the Card Array of my Form" like this
public Card[] GameCards { get { return this._GameCards; } } where _GameCards is the private array your created previously.
Dont declare anything inside the Main method that create your main Form of the Game.