static void Main(string[] args)
{
int[] BoughtItems = { 1, 2 };
int[] equippedItems = { 1 };
var result = BoughtItems.Where(x => equippedItems.Any(any => any == x));
foreach (var el in result)
Console.WriteLine(el);
}
结果:1
你能展示你有什么和你需要什么吗,因为现在我看不到你所说的问题。
顺便说一句,这个结果是一样的:
class Itemm
{
public int Id { get; set; }
}
static void Main(string[] args)
{
List<Itemm> BoughtItems = new List<Itemm>() { new Itemm { Id = 1 }, new Itemm { Id = 2 } };
List<Itemm> equippedItems = new List<Itemm>() { new Itemm { Id = 1 } };
var result = BoughtItems.Where(x => equippedItems.Any(any => any.Id == x.Id));
foreach (var el in result)
Console.WriteLine(el.Id);
}
结果:1