Robert W. <Ro*****@discussions.microsoft.com> wrote:
I'm in the process of defining a very complex data model that consists of
dozens & dozens of properties. To keep things better organized I've decided
to embed some classes within the main class, such as this:
public class MainClass
{
public class SubClass
{
.
.
This works fine but yet when I define an EventHandler at the topmost level
(ie. just inside the MainClass) I can't seem to access it from the SubClass.
Here's the syntax I used:
public event System.EventHandler ModelEvent;
I was expecting to be able to access it from anywhere in the class. Any
idea why I can't?
Yes - because you need an instance of the main class to handle an event
for. Having an instance of SubClass doesn't give you an instance of
MainClass automatically. (It's not like Java's inner classes, it's like
Java's static nested classes.)
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too