【问题标题】:c#, unity - How to find index of list item, without predicatec#, unity - 如何在没有谓词的情况下查找列表项的索引
【发布时间】:2017-02-15 09:44:02
【问题描述】:
int indext = lair.dungeon.DungeonLairList.FindIndex(x => x.name == lair.name);

这是我的代码,但我不能断言,因为巢穴对象可以并且将具有相同的名称,而且很可能是所有其他属性,确定列表中的确切索引至关重要。

我该怎么做?

【问题讨论】:

  • 如果你正在寻找完全相同的实例,你不能只使用IndexOf吗?
  • 谢谢你,完全迷上了“FindIndex” :)

标签: c# list unity3d predicate


【解决方案1】:
var indext = Array.FindIndex(lair.dungeon.DungeonLairList, x => x.name == lair.name);

【讨论】:

    猜你喜欢
    • 2014-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-17
    • 1970-01-01
    • 2018-10-05
    • 2012-11-22
    • 2018-01-24
    相关资源
    最近更新 更多