title: c# - How to generate random ITIN
body: <p>How to generate an 9 digit ITIN number with 70-88 in the fourth and fifth digit?</p>
  
  <hr>
  
  <p>The IRS site says that </p>
  
  <p>An Individual Taxpayer Identification Number (ITIN) begins with the number 9 and has a range of **70-88 in the fourth and fifth digit. The range was extended to include 900-70-0000 through 999-88-9999, 900-90-0000 through 999-92-9999 and 900-94-0000 through 999-99-9999.</p>
  
  <hr>
  
  <p>My test is to validate that an error message is seen when user tries to input a valid ITIN</p>
  
  <p>My code is checking for fourth and fifth digit after getting a random number. 
  A better way would be to get a random number with 9xx-70-0000 to 9xx-88-9999</p>
  
  <pre><code>        int RangeOneBoundaryStart = 70;
          int RangeOneBoundaryEnd = 88;       
          int count = 100;
          string InvalidMsg = "Invalid Entry. Individual Tax Identification Numbers are not accepted.";
  
          Random rand = new Random();
  
          for (int i = 1; i &lt;=count; i++ )
          {
              int Rndm1 = rand.Next(900700000, 999889999);
              string num = Rndm1.ToString();                
              string chcknum = num.Substring(3, 2);
              int chcknumint = Int32.Parse(chcknum);
  
              if ( chcknumint &gt;= RangeOneBoundaryStart &amp;&amp; Rndm1 &lt; RangeOneBoundaryEnd)
              {
                  _applyPage.ClearField(VerifyElement);
                  _applyPage.EnterTextWithValue(VerifyElement, num);
                  _applyPage.Click(ClickAnotherElement);
                  _TestMethods.ValidateError(ElementToVld, InvalidMsg);
              }            
  
          }
  </code></pre>