Create variable just a number from text/number string - Razor CSHTML
<p>I have a variable <code>var1</code>. In the current context, it is pulled from the database and will be one of those values:  </p>

<blockquote>
  <p>2, 6, 7 6t, 7q, 8q, </p>
</blockquote>

<p>The number will only ever be single digit.</p>

<p>The number will only ever be the first characters in the variable.</p>

<p>I would like to create a single character variable (the number) from the variable I have put in.</p>

<p>Here for instance my variable <code>Fac1Raw</code> has the value of <em>3c</em> and I have tried to use this code:</p>

<pre><code>var Fac1 = (int)(Fac1Raw.ToString().Substring(0, 1));
</code></pre>

<p>However I can't get it to work. Any ideas?</p>
