Cluj München 1140km

Gânduri clujene din Bavaria

München - Munich - Monaco di Baviera

27. august 2008 13:43
by skorpionking
0 Comentarii

.NET: Remove whitespace from a string with C#

27. august 2008 13:43 by skorpionking | 0 Comentarii

Am vazut vazut diferite metode de a elimina whitespace in C#. Eu am ales o metoda simpla, o extensie a clasei String folosind expresii regulate. Happy coding :-)

public static string RemoveWhitespace(this string str)
{
    if (!string.IsNullOrEmpty(str))
        return new Regex(@"\s*").Replace(str, string.Empty);
    else
        return str;
}

Adaugă comentariu

biuquote
Loading