Looping through indexof characters
Looping through indexof characters
(OP)
I'm new to C# - so I'm having trouble iterating through a string using indexof.
My String: "Hello|There|How|Are|You|"
I'm trying to loop through each found instance of the pipe character: "|" to provide a resultset like this:
Hello
There
How
Are
You
Simple and frustrating. But here is the last test code I have:
I've tried many different versions- but I can't find the correct code to loop through each iteration.
Thanks from a C# newbie.
Also - any site that has great string manipulation samples? I've found a few - but they never seem to show looping or conditional examples.
My String: "Hello|There|How|Are|You|"
I'm trying to loop through each found instance of the pipe character: "|" to provide a resultset like this:
Hello
There
How
Are
You
Simple and frustrating. But here is the last test code I have:
CODE --> C#
string s = "Hello|There|How|Are|You|"; int sLength = s.LastIndexOf("|"); while (s.IndexOf("|") <= s.Length) { int startblock = s.IndexOf("|") + 1; int endblock = s.IndexOf("|", startblock); MessageBox.Show(s.Substring(startblock, endblock - startblock)); }
I've tried many different versions- but I can't find the correct code to loop through each iteration.
Thanks from a C# newbie.
Also - any site that has great string manipulation samples? I've found a few - but they never seem to show looping or conditional examples.

RE: Looping through indexof characters
http://www.dotnetperls.com/indexof
Ed
RE: Looping through indexof characters
CODE
MakeItSo
“Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.” (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.