[Mono-list] Obtaining a generic MonoMethod

Robert Jordan robertj at gmx.net
Mon Dec 4 04:17:11 EST 2006


Robert Jordan wrote:
> You call methods of generic classes like every other method.
> The "trick" is to get the method from the "inflated" class,
> which you can obtain from mono_object_get_class ().
> 
> MonoClass *clazz = mono_object_get_class (obj);
> 
> /*
>   * untested. If there are more Add methods declared, you
>   * may use mono_method_desc_search_in_class (clazz, ":Add(T)")

Substitute the correct type for "T", i.e. for IList<int>
the desc will be ":Add(int)".

>   */
> MonoMethod *method = mono_class_get_method_from_name (clazz, "Add", 1);
> 
> mono_runtime_invoke (method, obj, args, &exception);



More information about the Mono-list mailing list