I'm doing simple string input parsing and I am in need of a string tokenizer. I am new to C# but have programmed Java, and it seems natural that C# should have a string tokenizer. Does it? Where is it? How do I use it?
The do-while statement lets you repeat a statement or compound statement until a specified expression becomes false.
The ' |= ' symbol is the bitwise OR assignment operator.
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) { Console.WriteLine(word); // there // is // a // cat } } }
For more information see Sam Allen's article about splitting strings in c# (Performance, Regex)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With