Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7076469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:18:07+00:00 2026-05-28T06:18:07+00:00

Consider that I have an interface that contains the following property interface IFoo {

  • 0

Consider that I have an interface that contains the following property

interface IFoo
{
    Int32 Id { get; }
}

Now say I want to create an IMutableFoo interface. Logically I would think that the following was correct:

interface IMutableFoo: IFoo
{
    Int32 Id { set; }
}

My thought is that it would inherit Id and then in my child interface I’d make it settable. To my surprise, this did not work. Instead I get a warning letting me know that I’m in fact overriding the Id in IFoo with the Id in IMutableFoo. I tried changing { set; } to { get; set; } with the same results. How do I do this right? In Java, I would simply add a setId method. How do I do this in C#? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:18:08+00:00Added an answer on May 28, 2026 at 6:18 am

    Re-declaration of Id in the descendent interface indeed hides the one in the parent.

    I use two different workarounds for this, entailing tradeoffs that I do not particularly like.

    1 – Using an abstract or even a non-abstract class instead of a mutable interface.

    interface IFoo {
        Int32 Id { get; }
    }
    abstract class MutableFoo: IFoo {
        public abstract Int32 Id {get; set;}
    }
    

    The biggest drawback is that the users of your library can no longer program to an interface.

    2 – Using a method instead of a property.

    interface IFoo {
        Int32 Id { get; }
    }
    interface IMutableFoo: IFoo {
        void SetId(Int32 value);
    }
    

    This is not ideal, because the setter is not idiomatic, and looks disconnected from the getter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets consider that I have a public property called AvatarSize like the following, public
Let's consider we have QWidget that contains QTableWidget (only). So we want to resize
Consider the following. You have a class that you want to serialize with XmlSerializer
Consider following scenario: I have RESTful URL /articles that returns list of articles user
Consider a situation. I have an in-proc COM server that contains two COM classes.
If I have interface IFoo, and have several classes that implement it, what is
Let's say I have an interface IAutoTask and few other classes implementing that interface,
Say for example, I have the following: public interface IPet { long? Id {
Consider searching a table that contains Apartment Rental Information: A client using the interface
Consider that I have a transaction: BEGIN TRANSACTION DECLARE MONEY @amount SELECT Amount AS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.