How to pass an Object type to Type parameter in C#
问题 I have a function that has Type Parameter. public static object SetValuesToObject(Type tClass, DataRow dr) { // ............. // return object } I have no idea how to pass a class as parameter for this function. Here i want to pass parmeter Class "Product". I tried this SetValuesToObject(Product,datarow); But it doesn't work. How could i do this? 回答1: The typeof keyword when you know the class at compile time. SetValuesToObject(typeof(Product),datarow); You can also use object.GetType() on