title: $string.Substring Index/Length exception
body: <p>I'm doing the following to try and get the last character from the string (in this case, &quot;0&quot;).</p>
  <pre><code>$string = &quot;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\hid\Parameters\0&quot;
  $parameter = $string.Substring($string.Length-1, $string.Length)
  </code></pre>
  <p>But I'm getting this Substring-related exception:</p>
  <pre class="lang-none prettyprint-override"><code>Exception calling &quot;Substring&quot; with &quot;2&quot; argument(s): &quot;Index and length must
  refer to a location within the string.
  Parameter name: length&quot;
  At line:14 char:5
  +     $parameter = $string.Substring($string.Length-1, $string ...
  +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : ArgumentOutOfRangeException
  </code></pre>
  <p>I understand its meaning, but I'm not sure why I'm getting given the index and length are correct.</p>
  <p>Even attempting to hard code it throws the same exception:</p>
  <pre><code>$parameter = $string.Substring(68, 69)
  </code></pre>
  <p>Is there something I'm missing?</p>