So basicilly I wanna save the list datas to csv.But the only thing is saved in the file is: System.Collections.Generic.List`1[WindowsFormsApp1.Autok],I dont know excatly how to fix,the writer is screwd up
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
List<Autok> aLista = new List<Autok>();
Autok a = new Autok();
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
string NewGUID = System.Guid.NewGuid().ToString();
tbTermekkod.Text = NewGUID.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
a.Termekkod = tbTermekkod.Text;
a.Gyarto = tbGyarto.Text;
a.Tipus = tbTipus.Text;
a.Szin = tbSzin.Text;
a.Felszereltsegiszint = tbFelsz.Text;
a.Ar = Convert.ToInt32(tbAr.Text);
aLista.Add(a);
}
private void button3_Click(object sender, EventArgs e)
{
using (StreamWriter sW = new StreamWriter(@"C:\Users\Tamás\source\repos\WindowsFormsApp1\WindowsFormsApp1\bin\Debug\rainbow.csv", false, Encoding.Default))
{
foreach (Autok item in aLista)
{
sW.WriteLine(a);
sW.Close();
}
}
}
}
}