Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

StringBuilder Extensions

0.00/5 (No votes)
30 Nov 2010 1  
A note about StringBuilder Extensions

Forgive me for sounding a little pedantic, but wouldn't you be able to use the LTrim and RTrim functions within the Trim function? (You'll have to forgive my syntax, I'm more of a Delphi guy myself). "Re-writing" the same code in separate places tends to cause issues when you need to update it, or at least that's what I've found when working on my code Smile | :) .

/// <summary>
/// Trim spaces around string
/// </summary>
/// <param name="sb"></param>
/// <returns></returns>
public static StringBuilder Trim(this StringBuilder sb)
{
    sb = LTrim(sb);
    sb = RTrim(sb);
    return sb;
}

Thanks,
Glen Vlotman

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here