Passing generic parameter results in wrong overload being called

前端 未结 1 573
名媛妹妹
名媛妹妹 2021-01-28 21:40

I\'m trying to update Medusa to allow decorated POCOs to be used anywhere it currently uses List. The problem I\'m running into is that the wrong

相关标签:
1条回答
  • 2021-01-28 22:01

    Yes, the overload is resolved at compile-time. You can force it to be evaluated at execution time if you're using C# 4, like this:

    internal T CallDoSomething<T, U>(string someString, U ints) where T : class
    {
        dynamic d = ints;
        return DoSomething<T>(someString, d);
    }
    

    However, personally I'd try to simplify your design if you possibly can. This sort of thing gets messy very quickly.

    0 讨论(0)
提交回复
热议问题