title: Auto generated id with character i made
body: <pre><code>string SetTeacherId()
      {
          char digit = 'T';
          string id = "";
          var count = db.Teachers.Count();
          if (count &gt; 0)
          {
              var str = db.Teachers.OrderByDescending(a =&gt; a.TeacherID).Select(a =&gt; a.TeacherID).First();
              string digits = new string(str.Where(char.IsDigit).ToArray());
              string letters = new string(str.Where(char.IsLetter).ToArray());
              int numbers;
              if (!int.TryParse(digits, out numbers))
              {
  
              }
              id += letters + (++numbers).ToString("D4");
  
              return id;
          }
          else
              return digit +"0001";
      }
  </code></pre>
  
  <p>In here i make a method called SetTeacherId. To be honest it made by my senior. The Teacher Id will auto increment. Can someone make a lot simpler code to auto generate id, because it a little bit confused.</p>