【问题标题】:How to find index of an item in a List<> where two or more property need to be check如何在需要检查两个或多个属性的 List<> 中查找项目的索引
【发布时间】:2016-04-14 17:33:18
【问题描述】:

如何在 List 中查找 两个或多个属性 需要检查的项目的索引?

这行得通:

int index = myList.FindIndex(a => a.Prop == oProp);

这不起作用:

int index = myList.FindIndex(a => a.Prop1 == oProp1 && a => a.Prop2 == oProp2);

【问题讨论】:

    标签: c# search indexing find


    【解决方案1】:

    您需要做的就是:

    int index = myList.FindIndex(a => a.Prop1 == oProp1 && a.Prop2 == oProp2);
    

    【讨论】:

    • 感谢您的帮助 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多