?
Solved

an array of events

Posted on 2004-10-12
1
Medium Priority
?
458 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
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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

839 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