Używanie funkcji do formatowania stringów w C#

0

Chciałbym zapisać poniższy kod w jednej linijce. Jakie będzie poprawne użycie kolejności funkcji (o ile jest to możliwe)?

tekst= tekst.Trim();
tekst= tekst.Remove(tekst.Length - 1);
2

tekst = tekst.Trim().Remove(tekst.Trim().Length -1); ??
Chyba lepiej zrobić to w dwóch linijkach.

1
string text = "abcde".RemoveLastCharacter();

A gdzieś jeszcze:

static class StringExtensions
{
    public static string RemoveLastCharacter(this string text)
    {
        var result = text.Trim();
        result = text.Remove(text.Length - 1);
        return result;
    }
}

1 użytkowników online, w tym zalogowanych: 0, gości: 1