現在、コレクション内のアイテムのメンバー式を使用してメソッドを実行するのに苦労しています。コレクションのメンバーを直接保持するメンバー式を記述する方法は知っていますが、基になる型を使用するようにどのように指示できますか。
private Collection<TestClass> collection { get; set; }
DoSomethingWithCollection(collection, () => collection.Count);
private void DoSomethingWithCollection(Collection<TestClass> collection, MemberExpression member)
{
foreach(var item in collection)
{
//use reflexion to get the property for each item
//based on the memberexpression and work with it
}
}
DoSomethingWithCollection の呼び出しがコレクションの基になる型の Memberexpression を保持できるようにするには、このコードをどのように書き直す必要があるのでしょうか。