I have this code that reads a csv file and on every line it uses line.split(',')
to sort each part of one line into values
, a string array.
How would I then put "values[1]" into it's own array?
static void Main(string[] args)
{
string line;
string[] countrys;
using (StreamReader sr = new StreamReader("Countries_database.csv"))
{
try
{
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine();
var values = line.Split(',');
Console.WriteLine(values[1]);
}
countrys = values[1];
}
catch(Exception ex)
{
Console.WriteLine("The file could not be read {0}", ex);
}
}
}
The countrys = values[1];
does not work but it just shows what I am aiming to do.
Many Thanks!