So, im using this code to find random value from my enum:
public cards chooseFromDeck()
{
var random = new Random();
return (cards)random.Next(cards.GetNames(typeof(cards)).Length);
}
and this is my Enum:
public enum cards { Ace=1,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten,Jack=10,Queen=10,King=10}
and I have 2 problems with this, 1. it somehow picks up "0" as a value, which I dont understand since I have my Ace marked as "1", and the 2nd problem is that it doesn't pick Jack,Queen and King at all, if I remove the "=10" from them all it works, but then the values are 11,12,13. What way should I use to add value "10" to Jack, Queen and King?
Aucun commentaire:
Enregistrer un commentaire