Answer the question
In order to leave comments, you need to log in
How to determine if a Delegate instance returns a value?
There is a Dictionary
, I get a certain theGuid, and I must execute what is hidden in the Dictionary under this guid and return a value in case it is required. So how do you know if a value is required? The first thing that comes to mind is try...catch, but somehow it's not pretty.
Like so
if (theDictionary.ContainsKey(theGuid))
{
dynamic FuncOrMethod = theDictionary[theGuid];
try
{
object o = FuncOrMethod(params);
// далее еще один трай будет на выполнение без возврата значений для проверки того, правильно ли переданы параметры
}
}
Answer the question
In order to leave comments, you need to log in
Try like this:
static bool IsAction(Delegate x){
return x.Method.ReturnType==typeof(void);
}
and if these 32 conditions are grouped according to similar semantics? Or at least break it down?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question