How to use a Type variable in a generic method call (C#)

前端 未结 2 330
南旧
南旧 2021-01-25 08:08

I have a Type variable t passed into a method, and I want to use it as a generic parameter when calling IQueryable.Join like the following



        
2条回答
  •  借酒劲吻你
    2021-01-25 08:40

    I'm not sure of the details of your "type variable," but if the variable is already a generic parameter to the method, you can use it as a generic parameter to Join also:

    public void MyMethod()
    {
        // do some stuff to get queryResult, then
        queryResult.Join(items, outerSelector, innerSelector, (a, b) => something);
    }
    

提交回复
热议问题