luvcloud
June 11th, 2002, 10:50 PM
i have two classes which wil fire the same event which i called Error event. currently what i have is in each of these classes i have declared the same delegate and events that will be fired by the class. the event handler is actualy in another class - MainForm, which contains the GUI. so that means in MainFOrm, i have something like this:
ClassA.Error += new ClassA.ErrorDelegate (onError);
ClassB.Error += new ClassB.ErrorDelegate (onError);
public void onError(int cmd, String s) {
switch (cmd) {
....
}
}
it's like a redundancy to write two same delegates in two different classes. Is there are way i could like put the delegate into another class, and ClassA and ClassB can use it? how will the event be fired then? and how will the MainForm know?
ClassA.Error += new ClassA.ErrorDelegate (onError);
ClassB.Error += new ClassB.ErrorDelegate (onError);
public void onError(int cmd, String s) {
switch (cmd) {
....
}
}
it's like a redundancy to write two same delegates in two different classes. Is there are way i could like put the delegate into another class, and ClassA and ClassB can use it? how will the event be fired then? and how will the MainForm know?