jeudi 30 juillet 2015

Random Number Issue C#

I am learning to use C# at the moment, and am just making random things I think of, so basically this is a "credit card generator" which obviously doesn't make real card numbers, just a random 16 digit number, with the CVV and Exp date.

So far, I can get it to print the Exp date, but as for the credit card number, I am getting an error which says -

"Cannot convert from long to int" and also a message stating the best overloaded method.

I am also having some problems with the date function, I can get it to generate 6 numbers ok, eg, day and year, but if i try to add another 2 numbers, it spits out 6 still.

Here is my code, sorry if this makes no sense, like I said, I am new to this :)

Thanks in advance for any help.

private void button1_Click(object sender, EventArgs e)
    {


        Random rnd = new Random();
        double cardNumber = rnd.Next(4572000000000000, 4999999999999999);
        int cvv = rnd.Next(001, 999);
        int expDay = rnd.Next(1, 30);
        int expMonth = rnd.Next(1, 12);
        int expYear = rnd.Next(2011, 2015);

        textBox1.Text = cardNumber.ToString();
        textBox2.Text = cvv.ToString();
        textBox3.Text = expDay.ToString() + expMonth.ToString() + expYear.ToString();

    }

I will say this again just to make this clear, this in no way makes real credit card numbers, they are just randomly generated digits.....




Aucun commentaire:

Enregistrer un commentaire