In my program I have two arrays which read in values from a CSV file. This CSV file has two columns. I split each column into a different array. On my form I have created a List Box called 'lbDinner', currently this is completely empty. What I im stuck on doing is adding both those arrays to the list box to be displayed for the users to choose an option.
This is all the code currently on my form, I am not sure where to go from here.
public partial class Dinner : Form
{
string dinner;
List<string> dinner_meal = new List<string>();
List<string> dinner_price = new List<string>();
public Dinner()
{
InitializeComponent();
dinner = "..\\Debug\\Dinner.csv";
var dinner_reader = new StreamReader(dinner);
while (!dinner_reader.EndOfStream)
{
var line = dinner_reader.ReadLine();
var values = line.Split(',');
dinner_meal.Add(values[0]);
dinner_price.Add(values[1]);
}
}
private void Dinner_Load(object sender, EventArgs e)
{
}
}
I am reading in a csv file called Dinner with the meal in the first column and the price of the meal in the second column. There is around 20 rows within this csv file.
As a summary, I want dinner_meal and dinner_price to both display in my listbox beside eachother as each dinner has its own unique price but I am not sure how to accomplish this. Thanks.