-
Split?
I am trying to figure out the "split", but, another option could be great too.
String to divide up: SETUP|variable1&Variable2
Now, in split, each one i've seen uses the 'foreach' statement in all of the examples.
I dont want the 'foreach', i want to be able to pull the variable1...and the variable2.
I know I can do the replace to ditch the SETUP|, so more so, how to pull to the left, and the right..of &
-
Re: Split?
So what's the general pattern? Will it always be a value followed by a pipe followed by a value followed by an ampersand followed by a value, or could it be something different?
-
Re: Split?
the & will be the divider.
So it'll be blahblahblah&yaydedodork
Each example i saw uses foreach...
I want to just pull the blahblahblah, or the yaydedodork... which change...
-
Re: Split?
You've now contradicted yourself. Your first post shows a pipe and your second doesn't. You need to be CLEAR. If we don't know what you actually want then we can't help you achieve it.
-
Re: Split?
I didnt contradict myself...
2 variables, seperated with a &...
In all the examples, they use a "foreach" command... ok, i got that.
BUT, how do I pull to the left...or to the right of the &? and not the other
-
Re: Split?
Have you looked at the documentation for the Split method rather than just examples? That should help you along your way.
-
Re: Split?
You did contradict yourself, but I'm not sure it matters. Have you checked the documentation for the String.Split method to see what it returns? Think about it. You say that the examples you've seen use a foreach loop. What are foreach loops usually used with? Arrays and collections, right? How do you usually get items by index from an array or collection?
-
Re: Split?
TCarter - what's the code you've tried that's not working?
If you don't know where to start, start with google and a search like this:
C# Split Examples