Possible Duplicate:
is there a generic Parse() function that will convert a string to any type using parse?
我想做一个泛型函数来做一些操作,比如:
ConvertValue<T>(string value)
如果T
是int
,则函数会将值转换为int
并返回结果.
类似地,如果T
是boolean
,函数将把value
转换为boolean
并返回它.
怎么写这个?