Tokenize strings : String Split Join « String « C# / CSharp Tutorial






using System; 
 
class MainClass { 
  public static void Main() { 
    string[] input = { 
                      "100 + 19", 
                      "100 - 87" 
                     }; 
    char[] seps = {' '}; 
 
    for(int i=0; i < input.Length; i++) { 
      string[] parts = input[i].Split(seps); 
      Console.Write("Command: "); 
      for(int j=0; j < parts.Length; j++) 
        Console.Write(parts[j] + " "); 
    } 
  } 
}
Command: 100 + 19 Command: 100 - 87








5.19.String Split Join
5.19.1.Joining strings
5.19.2.Splitting strings by |
5.19.3.Split strings by three tokens
5.19.4.String joins
5.19.5.Tokenize strings
5.19.6.String Split
5.19.7.Split string with \\
5.19.8.Sample for String.ToCharArray(Int32, Int32)