How to pass a method as a parameter


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
I want to set up a General Purpose type method which will have two parameters, a Business Object, and a Method Name of the business object. The method then needs to just run the method.

e.g.

private void RunABoMethod(BusinessObject myBo, Methodname MyMethodname))
{
      myBO.MyMethodname;
}
so some examples of how this might be called:
RunABoMethod(CustomerBO,"GetAllrecords");
or
RunABomethod(StockBO,"GetTop20");


Any suggestions / coding examples on how this might be accomplished (c#) would be appreciated. A few searches indicate that Func (Dot Net 3.5) or delgates could be used but I have no experience of using these constructs
Reply
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Edhy.

Yes, I was trying to make this fairly Generic, though I see your  point about using an enumeration as a possible way to go.

I think this can be done using Delegates and/or functions , just have no experience of using them... perhaps someone familiar with these might jump in.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search