C# Getting Last Character of String
If we want to get the last character of a string, we can do this using the Substring() and Length methods.
The following example shows how it is done..
namespace ConsoleApplicationTest
{
class Program
{
static void Main(string[] args)
{
string myStr = "I love coding";
string lastChar = myStr.Substring(myStr.Length - 1);
Console.WriteLine(lastChar);
Console.ReadLine();
}
}
}
It will be printed on the screen as "g".