LastChar

public static class MehrdadExtensions
{
    public static string LastChar(this string input)
    {
        if (!string.IsNullOrEmpty(input))
        {
            if (input.Length >= 1)
            {
                return input.Substring(input.Length - 1, 1);
            }
            else
            {
                return input;
            }
        }
        else
        {
            return null;
        }
    }
}
Example:
        string name = "mehrdad";
        Response.Write("Name is : " + name);
        Response.Write("<br />");
        Response.Write("Last Char : "+name.LastChar());

Description

Select Last character in string .

Details

Double click on the code to select all.

 

;