Way to retrieve last character of the string.
public string GetLast(string s, int tail_length)
{
if (tail_length >= s.Length)
return s;
return s.Substring(s.Length - tail_length);
}
eg.
string OneYearLastChar = GetLast(System.DateTime.Now.Year.ToString(), 1);
- Get Last Character
string TwoLastChar = GetLast(System.DateTime.Now.Year.ToString(), 2);
- Get Last Two Character
C# Retrieve/Get Last Character
Posted by Unknown at 3/14/2013 01:51:00 pm
Labels: ASP.net C#
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment