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
Sherif Ahmed
NA
6
0
Why is there a need to re-declare a method as "abstract" in an abstract class inheriting an interface
Mar 31 2009 2:15 PM
I have a basic C# question that I thought I’d seek your help on. In Java the following class structure is legitimate (and makes logical sense as AddInterfaceImpl is an abstract class and should not be obligated to implement all methods from the Interface it implements). However the equivalent C# code throws error indicating that AddInterfaceImpl does not implement all the methods of the underlying interface). C# forces me to declare GetString() as an abstract method in AddInterfaceImpl to avoid compiler errors. Does someone have a logical reason as to why GetString() has to be re-declared as Abstract in the AddInterfaceImpl class ? Java Code (Legal) public interface AnInterface { public String GetString(); } public abstract class AnInterfaceImpl implements AnInterface { public AnInterfaceImpl() { GetString(); } } C# Equivalent interface AnInterface { string GetString(); } //Will Throw compilation error // GetString has to be declared in AbstractImpl as string abstract GetString() in order to avoid compiler errors public abstract class AbstractImpl : AnInterface { public AbstractImpl() { GetString(); } }
Reply
Answers (
5
)
how to stop dragging window with titlebar
Printing Cyrstal report from button