I have a homework assignment in which I've been tasked with randomizing 5 cards out of my array cardArray
of type SuperCard
using the Random
class with all values returned as an array of type SuperCard
. What I'm getting hung up on is how to cast my custom type SuperCard
to int
in order to use the Next()
method from the Random
class. What I have thus far is ;
SuperCard[] hand = new SuperCard[5];
for (int index1 = 0; index1 <= 4; index1++)
{
hand[index1] = rand.Next(cardArray[0], cardArray[51]);//cant figure out how to cast this
}
If I attempt to cast rand.Next((int)cardArray[0],(int)cardArray[51]);
I get the error "Cannot convert type SuperCard to int". I can convert the array to an integer array but not back again.