Search notes:

.NET: splitting strings with String.Split()

C-Sharp example to split strings

System.String has the method Split() that allows to split a string into pieces (or words).
using System;

class Prg {

   public static void Main() {

      String txt = "Hello, world! The words are: foo, bar, baz.";

      String[] words = txt.Split(
             new char[] { ' ', '.', ',', ':', '!', '?' },
             StringSplitOptions.RemoveEmptyEntries
          );

      foreach (String word in words) {
         Console.WriteLine(word);
      }

   }
}
Github repository .NET-API, path: /System/String/Split.cs

See also

The PowerShell operator -split.

Index