Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

an array of events

Posted on 2004-10-12
1
Medium Priority
?
456 Views
Last Modified: 2012-08-13
Hi,

I would like to create an array of events for a project that I'm working on - is this possible?

I'm not talking about having a single event call many handlers - I know how to do that.

Thanks
0
Comment
Question by:bhanley9681
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
a_goat earned 1600 total points
ID: 12294694
There's no way to directly create an array of events.  You can do it indirectly though:

public class MyEventManager
{
public event EventHandler MyEvent;
}

public class MyFoo
{
public MyEventManager[] OnEvent = new MyEventManager[10];
public MyFoo()
{
for (int I = 0; I < OnEvent.Length; I++)
OnEvent[I] = new MyEventManager();
}
}

Then you can add an event like:

MyFoo Junk = new MyFoo();
Junk.OnEvent[2].MyEvent += [blah blah blah]

You might even be able to do it in a sneakier way, so you don't have to use the "MyEvent" when assigning the event handler
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question