Passing just a type as a parameter in C#

前端 未结 7 793
广开言路
广开言路 2020-11-28 21:21

Hypothetically it\'d be handy for me to do this:

foo.GetColumnValues(dm.mainColumn, int)
foo.GetColumnValues(dm.mainColumn, string)

where t

相关标签:
7条回答
  • 2020-11-28 22:15

    You can do this, just wrap it in typeof()

    foo.GetColumnValues(typeof(int))
    
    public void GetColumnValues(Type type)
    {
        //logic
    }
    
    0 讨论(0)
提交回复
热议问题