Book a Demo

Author Topic: Events in C# classes/code  (Read 3503 times)

Ian Turner

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
  • Crumbs Chief!
    • View Profile
Events in C# classes/code
« on: October 21, 2002, 04:44:51 am »
How do I add an event declaration to a (C#) class?

Essentially, what I want in my generated code is something along the lines of

using System;

public class SomeClass
{
   public SomeClass() {}

   public event EventHandler Changed;

   public void OnChanged()
   {
       // do some stuff here
   }
}

I've tried reverse-engineering this and it adds an attribute of type event named EventHandler to the class. I'm assuming that if the reverse engineering doesn't work then there is no forward-engineering support for event, either. Would that be correct?

Are there any other ways of representing events?

Cheers
Ian