private void getAllRecords() { string records = readFileContent(filePath); try { string line; PaymentData p; double totalCost = 0; double payment = 0; using (StreamReader sr = new StreamReader(filePath)) { while ((line = sr.ReadLine()) != null) { if (line != "") { string[] str = line.Split('\t'); p = new PaymentData() { seq_no = str[0], datetime = str[1], payment = str[2], comment = str[3] }; paymentTable.Add(p); double.TryParse(p.payment, out payment); totalCost += payment; } } } this.totalCost.Content = totalCost + "(元)"; } catch (Exception) { MessageBox.Show("err founded,try again please!"); } }