title: c# string.length
body: <p>This simple code:</p>
  
  <pre><code>    [HttpPost]
      public ActionResult Check(string chosen_username, string email) {
          var lang = RouteData.Values["lang"]; ViewBag.Language = lang;
  
          string un; string em;
          try {
              un = chosen_username; em = email;
          }
          catch { un = ""; em = ""; }
  
          string s = un.Length.ToString();
          ViewBag.test = s;
  
          return View();
      }
  </code></pre>
  
  <p>Throws the object reference not set to an instance of an object-exception (on the line that reads "string s = un.Length.ToString();"</p>
  
  <p>Could anybody help a C# newbie out please?</p>