I use a delegate to dynamically choose between many ie functions
delegate bool CtrlTransfer(int xferLength, ref byte[] buffer); bool CtrlRead(int xferLength, ref byte[] buffer) { } bool CtrlWrite(int xferLength, ref byte[] buffer) { }
and they are used in the dispatch function as
byte[] RunTest(CtrlTransfer ctrlXferFunction, ) { ctrlXferFunction(); return someByteArray; }
The reason I'm using a delegate, rather than some kind of argument specifying the direction, is because ctrlXferFunction is called many times, and using if {..} else {..} gets really tedious everywhere.
Now my problem is that I do not know which control transfer function was actually called. If I try if(ctrlXferFunction == CtrlRead) a la Python or JavaScript, I get an error message that == cannot be used between the group of methods and CtrlTransfer.
Is there any way to find out which function was actually called?
(My apologies if I made any terminological errors. I'm new to C #)
source share