title: C#: how to get first character of a string?
body: <p>We already have <a href="https://stackoverflow.com/questions/3878820">a question about getting the first 16-bit <code>char</code> of a string</a>.</p>
  
  <p>This includes the question code:</p>
  
  <pre><code>MyString.ToCharArray[0]
  </code></pre>
  
  <p>and accepted answer code:</p>
  
  <pre><code>MyString[0]
  </code></pre>
  
  <p>I guess there are some uses for that, but when the string contains text we hopefully are all aware that a single 16-bit char cannot hold a character, even in the restricted sense where we actually mean "codepoint".</p>
  
  <p>I am a programmer but not a C# programmer. I am just trying to help an online colleague fix such a bug, in case you feel this is too basic a question.</p>
  
  <p>So if we have a string in C# in a <code>char</code> array, encoded in correct UTF-16, possibly including a surrogate pair as the first character/codepoint and thus potentially consisting of two <code>char</code>s, how do I get that first character?</p>
  
  <p>(I naïvely assume Microsoft provides a string function for this and that I don't have to manually check for surrogate pairs.)</p>