【发布时间】:2016-03-30 12:28:55
【问题描述】:
我有一个具有这样结构的对象:
public class CustomObject
{
public int CustomProperty{get;set;}
public string CustomStringProperty{get;set;}
public List<CustomObject> CustomObjects{get;set;}
}
我知道有很多方法可以拉出任何对象、其父对象或根据 CustomProperty 上的某些条件获取对象。
我想编写一些扩展方法或 linq,以便客户端可以访问每个对象及其属性。
当前客户有列表 --> List<CustomObject>();
例如。 ClientMethod(List<CustomObject> customObjs);
【问题讨论】:
-
我不确定您在寻找什么,但我有一个猜测。试试这个索引器:msdn.microsoft.com/en-us/library/6x16t2tx.aspx
-
不是直接回答你的问题,但你可以看看dvanderboom.wordpress.com/2010/04/05/…
标签: c# linq c#-4.0 extension-methods