String.Split in .Net FW - why no overload that takes a single string?
...e.g. Str开发者_如何转开发ing.Split(Delim As String).
Yes, it is odd, have cursed at it myself several times. Equally odd is that the Split() overloads that take a string were not available in .NET 1.x. Well, odder perhaps. Maybe some "not too many overloads!" paralysis here. The StringSplitOptions and Count arguments can generate a combinatorial number of them.
Fix it with an extension method:
public static class Extensions {
public static string[] Split(this string s, string separator) {
return s.Split(new string[] { separator }, StringSplitOptions.None);
}
}
And add the ones you need if you also want to cover StringSplitOptions and Count :)
精彩评论