TakeFirst
Returns the first X characters from a string.
Source
public static string TakeFirst(this string s, int num)
{
if(string.IsNullOrEmpty(s))
return s;
return (s.Length < num ? s : s.Substring(0, num));
}
Example
string someString = "Awesome";
string firstThree = "Awesome".TakeFirst(3);
//firstThree now is the string "Awe".