BatchGuy.App.Extensions.ExtensionMethods.RemoveBackspaces C# (CSharp) Метод

RemoveBackspaces() публичный статический Метод

public static RemoveBackspaces ( this value ) : string
value this
Результат string
        public static string RemoveBackspaces(this string value)
        {
            if (string.IsNullOrEmpty(value)) //put -1 for last index of as well
                return value;

            int lastOccurrence = value.LastIndexOf('\b');

            if (lastOccurrence == -1)
                return value;

            lastOccurrence += 1;

            StringBuilder result = new StringBuilder((value.Length - lastOccurrence) + 1);
            result.Append(value.Substring(lastOccurrence,  (value.Length - lastOccurrence)));

            return result.ToString().Trim();
        }