Text file into array of words

  • Thread starter Thread starter Bhagya
  • Start date Start date
B

Bhagya

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??
 
Bhagya said:
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
 
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];
 
Back
Top