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.

Recommended Answers

All 2 Replies

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.