M
mmmpie
I want to be able to hand off the inner functionality of a loop to a
delegate. However, I also need to be able to call one of a number of
delegates based on the context of the loop ( in this case what level Im
in in a tree ). Using delegates seems like an easy way to implement all
of the management, and is well understood.
Where Im having trouble is invoking a _single_ delegate out of the
invocation list.
Some simple test code:
class DelegateHolder
{
public TestDelegate imATest;
public void RunDelegate()
{
// this works
foreach (TestDelegate wc in imATest.GetInvocationList())
{
wc(1);
}
// this doesnt - runtime exception casting to TestDelegate[]
TestDelegate[] ds;
ds = (TestDelegate[])imATest.GetInvocationList();
ds[0](1);
ds[1](1);
ds[2](1);
}
}
delegate. However, I also need to be able to call one of a number of
delegates based on the context of the loop ( in this case what level Im
in in a tree ). Using delegates seems like an easy way to implement all
of the management, and is well understood.
Where Im having trouble is invoking a _single_ delegate out of the
invocation list.
Some simple test code:
class DelegateHolder
{
public TestDelegate imATest;
public void RunDelegate()
{
// this works
foreach (TestDelegate wc in imATest.GetInvocationList())
{
wc(1);
}
// this doesnt - runtime exception casting to TestDelegate[]
TestDelegate[] ds;
ds = (TestDelegate[])imATest.GetInvocationList();
ds[0](1);
ds[1](1);
ds[2](1);
}
}