954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

string splitting

hello, i want to be able to split this string: "StraightPath1, 1, 2" into 3 sections: name, x, y. but when i use this code:

string[] pieces = line.Split(',')


it only i can only read the last 2 parts like this:

string Name = pieces[0]; //output: null
      int X = convert.ToInt32(pieces[1]); //output: 1
      int Y = convert.ToInt32(pieces[2]); //output: 2

I would like some help on advanced splitting string options
thank you.

choover12
Newbie Poster
22 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

Works fine for me, are you sure you aren't doing something to Name before you check it?

Momerath
Nearly a Senior Poster
3,386 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558
 

nevermind. it works. i don't know why it didn't work the first time?

choover12
Newbie Poster
22 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: