所以,如果我开始我的代码一切都很好,但是当我到达它要求选择附件的部分时,我写下列表中的那个,但它只是说它不在那里我在做什么wronk ?
Console.WriteLine("Do you want any attachments on your gun?");
if(Console.ReadLine() == "Yes")
{
attachments.ToList().ForEach(i=> Console.WriteLine(i.ToString()));
Console.WriteLine("Choose A Attachment" + "\n");
string q = Console.ReadLine();
if (q != attachments.ToList().ToString())
{
Console.WriteLine("not found");
}
else if (q == attachments.ToList().ToString())
{
Console.WriteLine("attachment added");
}
}
答案 0 :(得分:0)
if (q != attachments.ToList().ToString())
应该是:
if (!attachments.Contains(q)) // You may need a .ToList() before .Contains
和
else if (q == attachments.ToList().ToString())
应该是:
else