I have two rather simple class methods coded in Ruby...my own each
iterator:
# Loop through each instruction in the block, yielding the result
from
# the specified code block.
def each(&logic)
@instructions.each {|instr| yield instr}
end
# Find the specified instruction parm (string) in the block.
Returns
# nil if parm not found.
def find(p)
self.each {|i| return i if i.parm.index(p) }
nil
end
I'm trying to recode this exact functionality in C#, and am just not
getting the Delegate stuff. Can you direct me to some online examples
or references that show how to pass a delegate into method that
implements an iterator? I'm just not getting all the new C#
terminology and syntax complexities, and I need to learn it. MSDN
isn't helping me at all. The following is quasi psuedo mock up of
what I'm trying to accomplish.
public void each(Delegate block)
{
foreach (FL_Instruction i in this.Instructions)
{
block;
}
}
public static FL_Instruction find(string parm)
{
FindParm fp = delegate(FL_Instruction i) { if
(i.Parm.IndexOf(parm) > 0) { return i; } };
this.each(fp);
return null;
}
Thanks for your time and consideration,
dvn