Generic method where T is type1 or type2

后端 未结 7 1853
陌清茗
陌清茗 2021-02-12 01:58

Is there a way to declare a generic function that the generic type is of type1 or type2?

example:

public void Foo(T number)
{
}         


        
7条回答
  •  野性不改
    2021-02-12 02:21

    I don't think this is currently possible.

    This question about creating a math library sort of covers the same ground, and includes some work arounds.

提交回复
热议问题