In C#, you can type:
int[] ia = new int[] { 1, 2, 3, 4 };
And it will initialize an array of ints, of Length 4, containing those numbers.
I have a class Card, representing a Card in a deck, and I want to be able to say something like:
Card[] ca = new Card[] { "4S", "5C", "AH" };
And have an array of Cards, the first Card being the 4 of Spades, then the 5 of Clubs, then the Ace of Hearts.
I already can do:
Card c = new Card("4S");
And have a Card representing the 4 of Spades.
Is this constructor type even possible? If possible, how would I create it?
PS: I know I could go:
Card[] ca = Cards.Parse("4S 5C AH");
Or something lame like that, but I'm hoping I can avoid that, and use prettier syntax.
Now that I've typed this all out, I feel a bit sheepish. I'm "that guy" now... #Guilty