Does C# have a String Tokenizer like Java’s?

You could use String.Split method.

class ExampleClass
    public ExampleClass()
        string exampleString = "there is a cat";
        // Split string on spaces. This will separate all the words in a string
        string[] words = exampleString.Split(' ');
        foreach (string word in words)
            // there
            // is
            // a
            // cat

For more information see Sam Allen’s article about splitting strings in c# (Performance, Regex)

Leave a Comment