Exclude numbers starting with a certain three digits in C#

c#

Solution

Well, you could write:

int num;
do {
   num = SSN.Next(100000000, 999999999);
} while (num >= 666000000 && num < 667000000);

(I originally used a string comparison too, but as we've always got exactly 9 digits, we can make a numeric comparison easily.)

Problem

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!

Original source