C# TrimStart with string parameter

后端 未结 9 681
轻奢々
轻奢々 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:34

    TrimStart and TrimEnd takes in an array of chars. This means that you can pass in a string as a char array like this:

    var trimChars = " .+-";
    var trimmed = myString.TrimStart(trimChars.ToCharArray());
    

    So I don't see the need for an overload that takes a string parameter.

提交回复
热议问题