TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Administrator
Tech Writer
2.2k
1.5m
Using a delegate in a subclass to override the virtual method in the superclass
Mar 26 2003 10:29 PM
When using a delegate method in SubClass, the method works as it should. The same if I cast SC to SubClass. However I wish that the delegate method in SubClass should override the method in SuperClass. Unfortunately, override is not a valid keyword when creating delegate methods and the delegate does not have any methods on it's own to designate it an override property. public class MainClass { public SuperClass SC; public MainClass() { SC = new SubClass(); SC.rotateCW(); // MessageBox with "CW/CCW called", correct! SC.rotateCCW(); // MessageBox with "CCW" <--- They should point to the same method!!! } public class SuperClass { public SuperClass() {} public virtual void rotateCW() {MessageBox.Show("CW");} public virtual void rotateCCW() {MessageBox.Show("CCW");} } // End superclass public class SubClass : SuperClass { public rotateCCWDelegate rotateCCW; public SubClass() { rotateCCW = new rotateCCWDelegate(this.rotateCW); } public override void rotateCW() { MessageBox.Show("CW/CCW called"); } public delegate void rotateCCWDelegate(); }
Reply
Answers (
1
)
Why can't add web reference?
List of available classes