separating a string delimited by "|" and storing in variables

  • Thread starter Thread starter VM
  • Start date Start date
V

VM

How can I separate a string that looks like this:

"John|Conner|34323|T3-1"

so I can place John in one variable, Conner in another variable, etc...?

I know you can do it by finding the special char ('|' in this case) and
calculating the size of the string, but there should be a faster way.

Thanks,
VM
 
VM said:
How can I separate a string that looks like this:

"John|Conner|34323|T3-1"

so I can place John in one variable, Conner in another variable, etc...?

I know you can do it by finding the special char ('|' in this case) and
calculating the size of the string, but there should be a faster way.

Thanks,
VM

string myString = "John|Conner|34323|T3-1";
string[] myStrings = myString.Split('|');

Erik
 
Thanks. Works great.


Erik Frey said:
VM said:
How can I separate a string that looks like this:

"John|Conner|34323|T3-1"

so I can place John in one variable, Conner in another variable, etc...?

I know you can do it by finding the special char ('|' in this case) and
calculating the size of the string, but there should be a faster way.

Thanks,
VM

string myString = "John|Conner|34323|T3-1";
string[] myStrings = myString.Split('|');

Erik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top