我正在尝试从文本文件中解析销售信息并将它们放入两个列表框
文本文件包含以下信息:
Sam West $10,000.00
Mae West $125,900.00
North West $2,000.00
Michelle Smith $25,000.00
John Smith $12,500.00
Martin Smith $19,900.00
David Sampson $32,500.00
Joan Sampson $5,990.00
Sam Sampson $10,000.00
Mae Sampson $125,500.00
North Sampson $2,000.00
Michelle West $25,000.00
John Johnson $12,500.00
Martin Johnson $19,900.00
David Johnson $32,500.00
Joan Johnson $5,990.00
Sam Hartmann $10,000.00
Mae Hartmann $125,100.00
North Hartmann $2,000.00
Michelle Hartmann $25,000.00
John Johnson $12,500.00
Martin Hartmann $19,900.00
David Hartmann $32,500.00
Joan Hartmann $5,990.00
我的代码在这里
private void btnReadInSalesData_Click(object sender, EventArgs e)
{
StreamReader reader = new StreamReader("SalesNumbers.txt");
List<int> numbers = new List<int>();
int intTotal = 0;
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
string[] tokens = line.Split(new char[] { '$' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string s in tokens)
{
if (int.TryParse(s, out intTotal))
numbers.Add(intTotal);
lstTotalSales.Items.Add(s);
}
}
这是输出的图片 http://s24.postimg.org/ylm8vl9at/output.jpg
只是我想阅读文本文件并将总销售额添加到 lstTotalSales 列表框并将全名添加到 lstNames 列表框。
谢谢