I am currently building a C# application that is generating a random 9 digit number each run through. I am looking for a way to exclude numbers starting with “666”. How would I go about writing a statement to exclude numbers starting with certain digits.
Here’s the code snippet just in case it helps.
Random SSN = new Random();
string temp = "";
int num = SSN.Next(100000000, 999999999);
temp = num.ToString();
Thanks!
Well, you could write:
(I originally used a string comparison too, but as we’ve always got exactly 9 digits, we can make a numeric comparison easily.)