delegates

  • Thread starter Thread starter ichor
  • Start date Start date
I

ichor

hi i created an example to demonstrate the use of delegates

DoubleOp []op= {new DoubleOp(MathOp.MultiplyBytwo),
new DoubleOp(MathOp.Square)};
for (int i =0 ; i<op.Length ; i++)
{
MessageBox.Show ("using operation " + i );
double result = op(10); //here i want to see the value of op how do
i do that?
MessageBox.Show (result.ToString());
}

when i type this in command window it gives me the foll

op[1].ToString()
"delegates.Form1+DoubleOp"

but i want to see MathOp.Square or MathOp.MultiplyByTwo

how do i do that?
thanx
 
ichor said:
hi i created an example to demonstrate the use of delegates

DoubleOp []op= {new DoubleOp(MathOp.MultiplyBytwo),
new DoubleOp(MathOp.Square)};
for (int i =0 ; i<op.Length ; i++)
{
MessageBox.Show ("using operation " + i );
double result = op(10); //here i want to see the value of op how do
i do that?
MessageBox.Show (result.ToString());
}

when i type this in command window it gives me the foll

op[1].ToString()
"delegates.Form1+DoubleOp"

but i want to see MathOp.Square or MathOp.MultiplyByTwo

how do i do that?


Use op[1].Method, which is a MethodInfo and can give you the rest of
the information (eg the DeclaringType and Name properties).
 
Back
Top