Passing just a type as a parameter in C#

前端 未结 7 813
广开言路
广开言路 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 21:58

    You can use an argument of type Type - iow, pass typeof(int). You can also use generics for a (probably more efficient) approach.

提交回复
热议问题