我正在尝试查找其“tag”属性不等于 null 的 ArrayList 的第一个元素的索引。
我以为我可以做点什么
ArrayList.IndexOf(p => p.tag != null);
或
ArrayList.IndexOf(*.tag != null);
但这些都不起作用。有没有一种方法可以仅将 IndexOf 与对象的属性一起使用?
最佳答案
尝试 Array.FindIndex
:
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the entire Array.
关于c# - ArrayList.IndexOf(通配符?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5034309/