C#: how to get first char of a string?

Solution 1:

Just MyString[0]. This uses the String.Chars indexer.

Solution 2:

Mystring[0] should be enough

Solution 3:

Try this,

string s1="good"; string s=s1.Substring(0,1);

Solution 4:

You can use LINQ

char c = mystring.FirstOrDefault()

It will be equal to '\0' if the string is empty.