public List <Reis> Parse(string txt) { List <Reis> reises = new List <Reis>(); string[] msg = txt.Split('\n'); for (int i = 0; i < msg.Length - 1; i++) { string[] concrR = msg[i].Split(';'); int? a, b, c, d; if (concrR[4] == "") { a = null; } else { a = Convert.ToInt16(concrR[4]); } if (concrR[6] == "") { b = null; } else { b = Convert.ToInt16(concrR[6]); } if (concrR[7] == "") { c = null; } else { c = Convert.ToInt16(concrR[7]); } if (concrR[8] == "") { d = null; } else { d = Convert.ToInt16(concrR[8]); } Reis r = new Reis(concrR[0], concrR[1], Convert.ToInt16(concrR[2]), Convert.ToInt16(concrR[3]), a, Convert.ToInt16(concrR[5]), b, c, d); reises.Add(r); } return(reises); }
public void SaveOne(Reis someReis) { try { using (StreamWriter sw = new StreamWriter(path, true, System.Text.Encoding.Default)) { sw.WriteLine(someReis.reisToString()); } } catch (Exception e) { Console.WriteLine(e.Message); } }