![](/img/trans.png)
[英]Type “object {System.Collections.Generic.List<T>}” VS “System.Collections.Generic.List<T>”
[英]Find() In a System.Collections.Generic.List<T>
我正在使用Telerik OrgChart控件。 我基本上是在努力从节点中提取渲染的字段。 您可以将OrgChartRenderedField添加到每个节点; 它具有一个称为Label的属性。
每个节点的每个OrgChartRenderedField包含在OrgChartRenderedFieldCollection中
public class OrgChartRenderedFieldCollection : System.Collections.Generic.List<OrgChartRenderedField>
Member of Telerik.Web.UI
它有一个叫做find()的方法
public T Find(System.Predicate<T> match)
Member of System.Collections.Generic.List<T>
摘要:搜索与指定谓词定义的条件匹配的元素,并返回整个System.Collections.Generic.List中的第一个匹配项。
参数:match:System.Predicate委托,它定义要搜索的元素的条件。
返回:与指定谓词定义的条件匹配的第一个元素(如果找到);否则为false。 否则,为类型T的默认值。
异常:System.ArgumentNullException:match为null。
我遇到的主要问题是我无法弄清楚如何在集合中搜索特定的OrgChartRenderedField对象,其中Label ='Some text'表示它是第三方插件。 希望知道有人的物体类型可以给我一个建议。 谢谢。
Find
方法是List<T>
。 用法需要委托,最简单的方法可能是使用lambda,如下所示:
var item = list.Find(o => o.Label == "Some Text");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.