By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,978 Members | 1,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,978 IT Pros & Developers. It's quick & easy.

Text file into array of words

P: n/a
Hello All,

Suppose the Contents of Text file is:
Name Age Address
AAA 5 #22
BBB 8 #99
-------------------------so on

Can anybody tell me how to split this and insert this into a
multidimensional array??

Jul 23 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Bhagya" <ja**********@gmail.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
Hello All,

Suppose the Contents of Text file is:
Name Age Address
AAA 5 #22
BBB 8 #99
-------------------------so on

Can anybody tell me how to split this and insert this into a
multidimensional array??
I would say:
First replace the \r\n by space.
Then use Split.
Adrian
Jul 23 '07 #2

P: n/a
"Bhagya" <ja**********@gmail.comha scritto nel messaggio
news:11**********************@57g2000hsv.googlegro ups.com...
Hello All,

Suppose the Contents of Text file is:
Name Age Address
AAA 5 #22
BBB 8 #99
-------------------------so on

Can anybody tell me how to split this
for each line

string[] values = line.Split(' ');
and insert this into a
multidimensional array??
DON'T use multidimensional arrays!

use something like

struct Person
{
public string Name;
public int Age;
public string Address;
}

Person p;
p.Name = values[0];
p.Age = values[1];
p.Address = values[2];

--
Help The New .Net Site! http://www.devbox4.net
Jul 23 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.