private void button1_Click(object sender, EventArgs e) { /*String ruta2 = "C:\\Users\\Pere\\source\\repos\\ConsoleBasicAplications\\StandardDataSet.csv"; * TextWriter txt = new StreamWriter(ruta2); * txt.WriteLine(textBox1.Text + " " + textBox2.Text + " " + numericUpDown1.Value); * txt.Close(); * Persons();*/ PersonList pl = new PersonList(); pl.FirstName = textBox1.Text; pl.LastName = textBox2.Text; pl.Age = numericUpDown1.Value.ToString(); pl.IsAlive = checkBox1.Checked; persons.Add(pl); listBox1.Items.Add(textBox1.Text + "," + textBox2.Text + "," + numericUpDown1.Value + "," + checkBox1.Checked); }
public void Persons() { String ruta = "C:\\Users\\Pere\\source\\repos\\ConsoleBasicAplications\\StandardDataSet.csv"; List <string> lines = File.ReadAllLines(ruta).ToList(); lines.RemoveAt(0); foreach (var linia in lines) { string[] content = linia.Split(','); PersonList pl = new PersonList(); pl.FirstName = content[0]; pl.LastName = content[1]; pl.Age = content[2]; pl.IsAlive = Convert.ToBoolean(Convert.ToInt32(content[3])); persons.Add(pl); listBox1.Items.Add(linia); } //UptadePerson(); }