我的目标是删除与字符串DonatorPlayer
if (targetPlayer == null)
{
player.Message("That is not online. Please try again when they are online so that they may be notified in due time.");
}
else
{
//switch (DonationCheck)
//{
foreach (string line in lines)
{
WhichLoopDelete += 1;
if (line == DonatorPlayer)
{
switch (DonationCheck)
{
case 0:
lines[WhichLoopDelete] = null;
File.Delete("Donators.txt");
File.Create("Donators.txt");
DonationCheck = 1;
break;
case 1:
TextWriter tw = new StreamWriter("Donators.txt");
//Here is where I need to delete the line
break;
}
}
}
//}
}
答案 0 :(得分:0)
只需使用:
lines = lines.Where(line => !line.Equals("DonatorPlayer")).ToArray();