title: How to limit console input
body: <p>I am trying to check user input which supposes to be a four-digit account number only. if the user enters more or less input. it would say &quot;invalid entry&quot;. I am not sure how to check var length in c#.</p>
  <pre><code>Console.WriteLine(&quot;Enter a four-digit account number&quot;);
          int acc = Convert.ToInt32(Console.ReadLine());
          int d = acc % 10; 
          acc = acc / 10; 
          if (acc % 7 == d)
              Console.WriteLine(&quot;Valid Account Number&quot;);
          else
              Console.WriteLine(&quot;Invalid Account Number&quot;);
  </code></pre>