Re: re help with array of functions more info
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Fri, 13 May 2005 07:24:38 +0100
<CobraStrikes@xxxxxx> wrote:
> I hope the following makes it clearer what I am trying to do.
>
> lets say I have 3 methods
>
> private int method1()
> {
>
> }
>
>
> private int method2()
> {
>
> }
>
>
> private int method3()
> {
>
> }
>
>
> How can I code the following
> setup the array
>
> method [] ArrayMethod = { method1,method2,method3 };
>
> and call by
> x=method[2];
You would do:
delegate int IntMethod();
IntMethod[] methods = new IntMethod[]{new IntMethod(method1),
new IntMethod(method2),
new IntMethod(method3)};
int x = methods[2]();
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.
- References:
- re help with array of functions more info
- From: CobraStrikes
- re help with array of functions more info
- Prev by Date: Re: C# - Problem to receive data from a C++ Dll
- Next by Date: Re: How to pass arguments to a property in C#?
- Previous by thread: re help with array of functions more info
- Next by thread: Datagrid DateTimepicker column style
- Index(es):
Relevant Pages
|