c# - Get Type of Parameter from Generic Delegate functions -


i have list of generic delegates in dictionary, see below delegate stub.

public delegate ttype condition<t, ttype>(t obj); 

i have object dictionary. need cast object correct type delegate. cond current delegate function defined in dll. suggestions or maybe possible way go it? thanks!

foreach (var cond in _conditiondict[key])             {                 try                 {                     object obj = board[key] ;                      type objecttype = obj.gettype();                       if (objecttype == condtype)// need find condition type                     {                         convert.changetype(obj, condtype);//need condition typpe                      }                  } 

if want retrieve type "t" instance of delegate, use call:

obj.gettype().getgenericarguments().first(); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -