BF2Statistics.StringExtensions.CutTolength C# (CSharp) Method

CutTolength() public static method

Returns the input string at the maximum lenght provided. Excess string length will be removed from the end of the string. This method is very similar to using String.SubString(0, maxLength), but without an exception being thrown if the lentgh is greater than the length of the string.
public static CutTolength ( this str, int maxLength ) : string
str this
maxLength int
return string
        public static string CutTolength(this string str, int maxLength)
        {
            // If input is less then max length, just return the string
            if (str.Length <= maxLength)
                return str;

            return str.Substring(0, maxLength);
        }