|
-
Jan 30th, 2011, 03:10 PM
#1
Thread Starter
Fanatic Member
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 &
-
Jan 30th, 2011, 05:20 PM
#2
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?
-
Jan 30th, 2011, 05:27 PM
#3
Thread Starter
Fanatic Member
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...
-
Jan 30th, 2011, 06:12 PM
#4
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.
-
Jan 30th, 2011, 07:16 PM
#5
Thread Starter
Fanatic Member
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
-
Jan 30th, 2011, 08:10 PM
#6
Re: Split?
Have you looked at the documentation for the Split method rather than just examples? That should help you along your way.
-
Jan 30th, 2011, 08:10 PM
#7
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?
-
Jan 31st, 2011, 12:41 PM
#8
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
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|