C# TrimStart with string parameter

后端 未结 9 683
轻奢々
轻奢々 2021-02-04 23:00

I\'m looking for String extension methods for TrimStart() and TrimEnd() that accept a string parameter.

I could build one myself but I\'m alw

9条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-04 23:43

    from dotnetperls.com,

    Performance

    Unfortunately, the TrimStart method is not heavily optimized. In specific situations, you will likely be able to write character-based iteration code that can outperform it. This is because an array must be created to use TrimStart.

    However: Custom code would not necessarily require an array. But for quickly-developed applications, the TrimStart method is useful.

提交回复
热议问题