dynamic return type of a function

后端 未结 5 1028
春和景丽
春和景丽 2021-02-07 04:46

How can I create a function that will have a dynamic return type based on the parameter type?

Like

protected DynamicType Test(DynamicType type)
{

retur         


        
5条回答
  •  孤城傲影
    2021-02-07 05:14

    Actually, assuming that you have a known set of parameters and return types, it could be handled with simple overloading:

    protected int Test(string p) {   ...  }
    protected string Test(DateTime p ) { .... }
    

提交回复
热议问题