gpt4 book ai didi

C# 和委托(delegate)

转载 作者:太空宇宙 更新时间:2023-11-03 17:57:16 25 4
gpt4 key购买 nike

我想使用一个委托(delegate),它允许我使用 FIND 搜索列表中的一个项目与另一个列表中的另一个项目的匹配。

我的代码工作如下: -

Type a = listname.Find(delegate(Type b))
{
return list.item == b.list.item;
}

如果列表项与 b 中的项匹配,则返回 a 中的项。这工作正常,但是我现在想检查是否只返回 a 如果 list.item 中有多个项目与 b.list.item 匹配,例如
Type a = listname.Find(delegate(Type b))
{
return list.item == b.list.item;
list.anotheritem == b.list.anotheritem
}

我似乎无法对其进行编码,以便在返回 Type a 之前检查多个条件。

最佳答案

Type a = listname.Find(delegate(Type b) 
{
return list.item == b.list.item &&
list.anotheritem == b.list.anotheritem;
}

关于C# 和委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7941065/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com