C# 我有一个控制台应用程序,它读取和写入“人员”详细信息的获取/设置列表。在我尝试将其写入文本文件之前,它都可以正常工作。有人能告诉我为什么这会将“人员”详细信息的最后一行写入我的文本文件而不是整个列表吗?
loadData();
Console.WriteLine("All People");
//1st query - just select all people
var queryAllPeople = from person in people select person;
foreach (Person p in queryAllPeople)
{
using (StreamWriter writer = new StreamWriter("people.txt"))
{
writer.WriteLine(p);
}
Console.WriteLine(p);
}
Console.ReadLine();