如何在此代码中转换teile[4]
为 a ?Color
public void Save(StreamWriter sw)
{
for (int i = 0; i < liste.Count; i++)
{
Buch b = (Buch)liste[i];
if (i == 0)
sw.WriteLine("ISDN ; Autor ; Titel ; Farbe");
sw.WriteLine(b.ISDN + ";" + b.Autor + ";" + b.Titel + ";" + b.Farbe);
}
}
public void Load(StreamReader sr)
{
int isdnn;
string autorr;
string titell;
Color col;
sr.ReadLine();
string line;
while((line = sr.ReadLine()) != null)
{
if (line.Length > 0)
{
string[] teile = line.Split(';');
try
{
isdnn = Convert.ToInt32(teile[0]);
autorr = teile[1];
titell = teile[2];
string color = teile[3];
col = Color.FromName(color);
}
catch
{
throw new Exception("Nicht geklappt");
}
Buch buch = new Buch(isdnn, autorr, titell, col);
liste.Add(buch);
}
}
}
如果我加载一些东西,它总是白色的