Skip to content

Instantly share code, notes, and snippets.

@longtth
Last active July 1, 2018 15:18
Show Gist options
  • Select an option

  • Save longtth/21bab15e693c41709fe1afbecde5d982 to your computer and use it in GitHub Desktop.

Select an option

Save longtth/21bab15e693c41709fe1afbecde5d982 to your computer and use it in GitHub Desktop.
1 cái Extension Method để extend cái class String, vẫn chép từ SO
// You can use an extension method:
public static class StringExtension
{
public static string GetLast(this string source, int tail_length)
{
if(tail_length >= source.Length)
return source;
return source.Substring(source.Length - tail_length);
}
}
// And then call:
string mystring = "34234234d124";
string res = mystring.GetLast(4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment