ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

GetFirst

get fist n charactor in string

Source

public static string GetLast(this string source, int tailLength)
{

    if (source == null || tailLength >= source.Length)
        return source;
    return source.Substring(source.Length - tailLength);
}

Example

string number = "123456789".GetFirst(5); //12345

Author: Phakawan Wongpetanan

Submitted on: 22 feb. 2014

Language: C#

Type: System.String

Views: 4869