title: C# 8 way to get last n characters from a string
body: <p>Recently VS hinted me to use the:</p>
  <pre><code>var str = &quot;foo&quot;;
  var str2 = str[^2..];
  </code></pre>
  <p>Instead of the:</p>
  <pre><code>var str = &quot;foo&quot;;
  var str2 = str.Substring(str.Length - 2);
  </code></pre>
  <p>So, my question is are there any differences between the <code>str[^2..]</code> and the <code>str.Substring(str.Length - 2)</code>? I think it is a new C# feature, but I was not able to find any documentation about it. So, I do not know how it is called and what version of C# does it come with.</p>
  <p>Here is what I was trying to google:</p>
  <p><code>^ in string access c#</code></p>
  <p>I did not get any related results. Should I google something else?</p>