I'm not sure if the title is clear so, I'm declaring an array in class, but the problem is that when I want to create a class the size of array might be different and by that I want to tell the size of array to the class by the constructor. Example.
const short DeckSize;
private char[,] Deck = new char[DeckSize, 2];
public HandDeck(short Size)
{
DeckSize = Size;
}
So the problem here is that array has to be a constant or static as my compiler says.
I found something about readonly attribute and tried to change code to this
readonly short DeckSize;
private char[,] Deck = new char[DeckSize, 2];
public HandDeck(short Size)
{
DeckSize = Size;
}
And it works (probably), but now the declaration doesn't meet the requirements. And at this point I am out of ideas. Any great suggestions here?