Пример #1
0
        public static string TrimToMax(this string target, int maxLength = 80, TrimToMaxOptions options = TrimToMaxOptions.None)
        {
            if (target == null)
            {
                return(null);
            }
            var elipsis = "...";

            if (options == TrimToMaxOptions.NoElipsis)
            {
                elipsis = string.Empty;
            }
            if (target.Length > maxLength)
            {
                return(target.Substring(0, maxLength - elipsis.Length) + elipsis);
            }
            return(target);
        }
Пример #2
0
 public static string TrimToMax(this string target, int maxLength = 80, TrimToMaxOptions options = TrimToMaxOptions.None)
 {
     if (target == null)
     {
         return null;
     }
     var elipsis = "...";
     if (options == TrimToMaxOptions.NoElipsis)
     {
         elipsis = string.Empty;
     }
     if (target.Length > maxLength)
     {
         return target.Substring(0, maxLength - elipsis.Length) + elipsis;
     }
     return target;
 }