I'm using C# and I need to generate a random 10 digit number. So far, I've only had luck finding examples indicating min maximum value. How would i go about generating a random number that is 10 digits, which can begin with 0, (initially, I was hoping for random.Next(1000000000,9999999999)
but I doubt this is what I want).
My code looks like this right now:
[WebMethod]
public string GenerateNumber()
{
Random random = new Random();
return random.Next(?);
}
**Update ended up doing like so,
[WebMethod]
public string GenerateNumber()
{
Random random = new Random();
string r = "";
int i;
for (i = 1; i < 11; i++)
{
r += random.Next(0, 9).ToString();
}
return r;
}
See Question&Answers more detail:os