samedi 7 mars 2015

How can I display pictures using an if/else statement for a coin flip app?

How can i display one image(heads) if coinFlip is equal to 1, and another image(tails) if its 2? Sorry if this is a stupid question, this is my first Win-Form app.



private void button1_Click(object sender, EventArgs e){

Random rand = new Random();

int heads = 1;
int tails = 2;
int coinFlip = rand.Next(heads, tails);

if (coinFlip == heads)
{
// Display heads picture
}

else
{
// Display tails picture
}

}

Aucun commentaire:

Enregistrer un commentaire