lundi 29 mai 2017

I cant Clean the Label

    private void cmdStart_Click(object sender, EventArgs e)
    {
        Random r = new Random();
        int iRnd = new int();
        int iRnd1 = new int();
        int iRnd2 = new int();
        iRnd = r.Next (0, 6); 
        iRnd1 = r.Next(0, 6); 
        iRnd2 = r.Next(0, 6); 

        if (iRnd == 0)
            pbTärnigVisa1.Image = pbTärning0.Image;
        else if (iRnd == 1)
            pbTärnigVisa1.Image = pbTärning1.Image;
        else if (iRnd == 2)
            pbTärnigVisa1.Image = pbTärning2.Image;
        else if (iRnd == 3)
            pbTärnigVisa1.Image = pbTärning3.Image;
        else if (iRnd == 4)
            pbTärnigVisa1.Image = pbTärning4.Image;
        else 
            pbTärnigVisa1.Image = pbTärning5.Image;
        //Dice1 IRnd
        //Dice2 IRnd1
        //Dice3 IRnd2

        bool r1 = (iRnd == iRnd1);
        bool r2 = (iRnd == iRnd2);
        bool r3 = (iRnd1 == iRnd2);
        bool r4 = (iRnd1 == iRnd2);
        var allEqual = new[] { r1, r2, r3 }.Distinct().Count() == 1;


        if (r1)
            lbl_resultat.Text = " 1 pair";
        if (r2)
            lbl_resultat.Text = " 1 pair";
        if (r3)
            lbl_resultat.Text = " 1 pair";
        if (allEqual)
            lbl_resultat.Text = " 3 Pair";
        else
            lbl_resultat.Text.Remove(0);

I cant clean the lable lbl_resultat. Can somne of you see the problem? The lable only types out " 3 pair" if not one of the prv values Thanks for Answers. And if you got any improvements feel free :D




Aucun commentaire:

Enregistrer un commentaire