C# – How to split a string

String can be split into collection of substrings based on a defined character (separator) using Split() function. Split is part of String class which exists in the System namespace.

Split function is overloaded and has various forms which allow to:

  • pass separator as a single character, array of characters, single string or array of strings;
  • define maximum number of substrings in output array;
  • define split options like removing empty elements from returned collection.
Continue reading C# – How to split a string