C# - Interface EVent Question

J

John Smith

I have an event in an interface, how do I implement this event in a
class? I have tried implements keyword and does not work.

public enum ActionEnum {Added, Removed};

public class ListChangedEventArgs : System.EventArgs
{
public Employee Item;
public ActionEnum Action;
}

public delegate void ListChangedEventHandler(object sender,
ListChangedEventArgs e);

public interface IServices
{
/// <summary>
/// Gets a list of all emplyees currently held on the server.
/// </summary>
/// <returns></returns>
System.Collections.ArrayList GetAllEmplyees( );

/// <summary>
/// Occurs when the list of employees maintained on the server
changes.
/// This is mainly triggered when a new employee is added or an
existing one
/// is removed from the list.
/// </summary>
event ListChangedEventHandler ListChanged;

}
 
K

Kris

Hi Jhon,

You dont need implement the event method. If you want to associate
event with a method in your class, use below statements in your class.

event ListChangedEventHandler ListChanged;

ListChanged += new ListChangedEventHandler(ListChanged_EventHandler);

Cheers,
Kris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top