rifter1818
Well-known member
Heres an odd situation ive got myself into, i want to create an array of what i would in C++ call function pointers,.. in a C# application...
pretty much what i would like to create is a situation like this
if my choice of (void(Object,EventArgs)) didnt give it away i am using these as functions that will be used to handle events, click events on buttons in this case allthought that is errelevant. There are other ways of doing this, but this one seems intreaging enough to ask whether it can be done or not, also can you have null elements.
(probably best explaned by a another code segment)
Once again i know there are other ways of avoiding needing this array, but still, can it be done? and what needs to replace (void(Object,EventArgs)) ?
pretty much what i would like to create is a situation like this
C#:
(void(Object,EventArgs))[] FPs = {fcNEW,fcLOAD,fcEDIT,fcWHATEVER...};
void fcNEW(Object Sender,EventArgs e){...}
void fcLOAD(Object Sender,EventArgs e){...}
//and so on
(probably best explaned by a another code segment)
C#:
void SetupButtons(string[] CAPTIONS,(void(Object,EventArgs))[] CLICKEVENTS)
{
for(int i=0;i<=CAPTIONS.GetUpperBound(0);i++)
{
cmdBUTTON[i].text = CAPTIONS[i];
cmdBUTTON[i].Click += new EventHandler(CLICKEVENTS[i]);
}
}