You must assign the value returned from rNum.Next(2,47)
to a variable as follows:
int rrNum = rNum.Next(2,47);
rNum
is of type Random
. You cannot convert this type to int
.
rNum.Next(2,47)
returns the int
you want. If you look at the documentation for Random.Next , you will see that its signature is of the type:
public virtual int Next(int minValue, int maxValue);
int
in public virtual int
is the return type of the method. You can use this information to determine what type of variable you need to store, which is returned from the call, to Next
.
Charles Lambert
source share