I\'m making a blackjack project..
I\'ve firstly created the Hit
class for the Hit
Button.
So on the form, when I click it, it will retr
what u have done is declared the stRefID
variable inside the scope of the method GenerateID
this is not gonna work so what u can do is put that variable within the scope of the class and then u can use it like this.
namespace Blackjack
{
public class Hit
{
string stRefID = "";
public static string GenerateID(int MinSize, int MaxSize)
{
Random random = new Random();
int iChosenMaxSize = random.Next(0, 11);
int two = 2;
int three = 3;
int four = 4;
int five = 5;
int six = 6;
int seven = 7;
int eight = 8;
int nine = 9;
int ten = 10;
int jack = 10;
int queen = 10;
int king = 10;
int ace = 11;
for (int x = 1; x <= iChosenMaxSize; x++)
{
int iCharType = random.Next(0, 12);
switch (iCharType)
{
case 0:
stRefID += two;
break;
case 1:
stRefID += three;
break;
case 2:
stRefID += four;
break;
case 3:
stRefID += five;
break;
case 4:
stRefID += six;
break;
case 5:
stRefID += seven;
break;
case 6:
stRefID += eight;
break;
case 7:
stRefID += nine;
break;
case 8:
stRefID += ten;
break;
case 9:
stRefID += ace;
break;
case 10:
stRefID += jack;
break;
case 11:
stRefID += queen;
break;
case 12:
stRefID += king;
break;
}
} return stRefID;
}
this should work fine i guess