Passing just a type as a parameter in C#

前端 未结 7 805
广开言路
广开言路 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条回答
  •  萌比男神i
    2020-11-28 22:15

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

    foo.GetColumnValues(typeof(int))
    
    public void GetColumnValues(Type type)
    {
        //logic
    }
    

提交回复
热议问题