خرید بک لینک

Vote count: 0

I need to call a method that receive a list of Func<T>, the problem is that the retu of the Func is not the same for all the items of the list.

For example:

//Having the following method:
public void DoSomething(params Expression<Func<T>> list)
{
 //do something
}

//and the following object
public class Foo
{
    public long Id { get;set; } //LOOK: ITS A LONG PROPERTY
    public string Name { get; set; } // ITS A STRING PROPERTY
}

//I would like to pass these two expressions of DIFFERENT retuing types.
Foo f = new Foo();
DoSomething(() => f.Id, () => f.Name); //TWO RETURN TYPES DIFFERENTS.

The compiler says that it's impossible because the method param is a Generic Type T, so all the Funcs passed needs to be the of the same retu type.

asked 2 mins ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: جمعه 14 اسفند 1394 ساعت: 1:28

صفحه بندی