Tech Off Post

Single Post Permalink

View Thread: Split and Join
  • User profile image

    Maybe I've always just missed the obvious, but is it just me who finds it extremely annoying that string.Split() and string.Join() expect different datatypes for the separator character? string.Join() expects a string value as the separator, and string.Join() expect either a char (via params), an array of chars or an array of strings. I'd have guessed that these two methods often operate on each other's output, and so defining a const separator value would be useful, but apparently not. The simplest way I can think of is defining the separator character as a const char, and then calling .ToString() on that char for the Join() method, but that's still a pain.

    What am I missing?