Is there a way to to declare a delegate, the instance of which will call methods with differing parameter numbers and types?
Here are excerpts of the code I am currently using:
Many thanks for any help on this.
Here are excerpts of the code I am currently using:
Code:
public delegate void CalcArrayDelegate();
...
public static CalcArrayDelegate arrayMethod;
...
public void AssignElement(List<VariableType> _masterVariableList, CalcArrayDelegate _calcMethod)
{
for (int i = 0; i < COUNTVARS; i++)
{
switch (this[i].GetType().ToString())
{
case "Type1":
{
Type1 currVar = this[i] as Type1;
string formula = String.Empty;
double value = 0;
// DELEGATE WITH THREE PARAMETERS, WITH VALUE (DOUBLE)
_calcMethod(i, ref value, ref formula);
...
break;
}
case "Type2":
{
Type2 currVar = this[i] as Type2;
double value = 0;
// DELEGATE WITH TWO PARAMETERS, WITH VALUE (DOUBLE)
_calcMethod(i, ref value);
inVar.AssignValue(value);
break;
}
case "Type3":
{
Type3 currVar = this[i] as Type3;
bool value = false;
// DELEGATE WITH TWO PARAMETERS, WITH VALUE (BOOLEAN)
_calcMethod(i, ref value);
inVar.AssignValue(value);
break;
}
...
Comment