title: Unique ticket numbers for software support system
body: <p>I'm developing a ticketing system for tracking bugs and software changes using ASP.NET MVC 4 and Entity Framework 5. I need a way to pick a unique number from a set of possible numbers. My thought is to create a set of possible numbers and mark numbers from this set as they are used and assigned to a support ticket. </p>
  
  <p>I have this code for generating all possible ticket numbers to choose from, but I want to have leading zeroes so that all ticket numbers have the same length:</p>
  
  <pre><code>public static class GenerateNumber
  {
      private static IEnumerable&lt;int&gt; GenerateNumbers(int count)
      {
          return Enumerable.Range(0, count);
      }
  
      public static IEnumerable&lt;string&gt; GenerateTicketNumbers(int count)
      {
          return GenerateNumbers(count).Select(n =&gt; "TN" + n.ToString());
      }
  }
  </code></pre>
  
  <p>I want the output of<br>
  <code>IEnumerable&lt;string&gt; ticketNumbers = GenerateNumber.GenerateTicketNumbers(Int32.MaxValue);</code><br>
   to be something like this:<br>
  TN0000000001<br>
  .<br>
  .<br>
  .<br>
  TN2147483647 </p>
  
  <p>Hopefully we won't need anything as large as <code>Int32.MaxValue</code> as that would mean we have way too many bugs haha. I just wanted to be safe than sorry on the limits of the available numbers. Perhaps we could use the methodology of reusing ticket numbers after they have been resolved. However, I don't know how I feel about reuse as it could lead to ambiguity for referring to documentation later on.</p>
  
  <p>Considering the size of this set, is this the most efficient method to go about having unique ticket numbers?</p>