If i have an interface:
interface IFoo { int Offset {get;} }
can i have this:
interface IBar: IFoo { int Offset {set;} }
so consumers of IBar will be able to set or get?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, you can’t!
(I was about to write ‘Yes’, but after reading Anthony’s post, and trying out a few tweaks, I found the answer to be NO!)
(Will generate a warning as Anthony points out, which can be fixed by adding the ‘new’ keyword.)
When trying out the code:
The last line will generate a compile error, since you have hidden IBar’s Offset setter.
EDIT: Fixed the accesibillity modifier on the property in the class. Thx Anthony!