c# - ArrayList.IndexOf(通配符?)

标签 c# .net collections

我正在尝试查找其“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/

相关文章:

c# - 如何从代码隐藏属性中获取样式属性的值?

c# - 将表值从一个表插入到另一个表

c# - .NET 的 MySql 驱动程序不支持多边形结构,是吗?

.net - 你能从开源中获得任何经济返回吗

c# - 在 Habanero 中,我将如何限制从数据库返回的对象数量

c# - 使用 DataContract 实现不同类型(bool?和 enum)之间的映射

c# - 属性错误: An attribute argument must be a constant expression, 属性参数类型的typeof表达式或数组创建表达式

java - 获取 java.util.ConcurrentModificationException

collections - Kotlin-来自两个集合的过滤器/ map

java - 为什么 TreeSet 抛出 ClassCastException?