我设法更改了各个字段,但最终删除了文件中的所有其他内容。我只想编辑一个字段。任何帮助将不胜感激。谢谢
这是我当前的代码:
这是我当前的代码:
C#:
public static void UpdatePatientData()
{
string detail, choice;
Console.WriteLine("Please enter the ID of the customer you would like to Update: ");
ID = Console.ReadLine();
string[] Name = File.ReadAllText("user.txt").Split('|'); // each field will represent an index from 1-4
for (int i = 0; i < Name.Length; i++)
{
if (Name[i].Contains(ID))
{
// here is where i would like to edit the name/gender/age etc 和 write it back to the file
}
}
}
Last edited: