Tao,
No, you can not. The type has to be known at compile-time in order to
make the call to the generic method like that.
What you can do is get the MethodInfo for the generic method, and then
call the MakeGenericMethod method on the MethodInfo instance. It will get
you a new MethodInfo instance which represents the method with the type
parameter that you pass in (you are going to pass in obj.GetType() in your
case).
Then, you can use reflection to make the clal on the MethodInfo
instance.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Tao" <tt*******@hotmail.comwrote in message
news:OZ**************@TK2MSFTNGP06.phx.gbl...
hi.. group
I have a question about generic fucntion. Let us say, I have a function
F<T>(int a);
can I do something like:
Type type = obj.GetType();
F<type>(3);
thanks.