Exemple #1
0
        /// <summary>
        /// Aggiunge padding a destra fino a length: 1 -> 1000. Opzionalmente spezza la stringa se piu lunga.
        /// </summary>
        public static string PadRight(this string str, char padChar, int length, bool truncate = false)
        {
            if (string.IsNullOrEmpty(str))
            {
                return(padChar.CharString(length));
            }

            if (str.Length > length && truncate == true)
            {
                return(str.Truncate(length));
            }

            if (str.Length < length)
            {
                return(str + padChar.CharString(length - str.Length));
            }

            return(str);
        }