public void NhapTuFile() { string path = @"data.txt"; StreamReader a = new StreamReader(path); string line = ""; while ((line = a.ReadLine()) != null) { string[] d = line.Split('*'); MayTinh hh = new MayTinh(); foreach (var item in d) { if (item.IndexOf("CPU") == 0) { hh.Them(new CPU(item)); } if (item.IndexOf("RAM") == 0) { hh.Them(new RAM(item)); } if (item.IndexOf("HDD") == 0) { hh.Them(new HDD(item)); } } Them(hh); } }
public void Them(MayTinh hh) { ds.Add(hh); }