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 8593343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:58:00+00:00 2026-06-11T23:58:00+00:00

I am running into an issue with field inheritance. First I will explain how

  • 0

I am running into an issue with field inheritance. First I will explain how I would like it to work, and then ask for suggestions on how I can change the syntax to do what I want.

Here’s what I tried:

public abstract class A
{
    public abstract D D1
    {
        get;
    }

    protected D _d2;
    public virtual D D2
    {
        get { return _d2; }
        set { _d2 = value; }
    }
}

public abstract class B : A
{
    protected D _d1;
    public override D D1
    {
        get { return _d1; }
        set
        {
            _d1 = value;
            Update();
        }
    }
}

public abstract class C : A
{
    public override D D1
    {
        get
        {
            return _d2.Find1();
        }
    }

    public override D D2
    {
        get { return base.D2; }
        set
        {
            base.D2 = value;
            Update();
        }
    }
}

The problem is that A doesn’t compile because it can’t find an method to override with D1’s set. This how I expected it to work:

A ab = new B();
print(ab.D1);
ab.D1 = 4; // I would expect a compiler error
((B)ab).D1 = 4; // I would expect a compiler error

A ac = new C();
print(ac.D1);
ac.D1 = 4; // I would expect a compiler error
((C)ac).D1 = 4; // **I would expect this to work**

One solution I can see would be to add “set;” to A1’s D1 and throw a NotImplementedException if I try to use it in C, but that would prevent the issue from showing up in the compiler. Anyone know of a way around this issue? I would really like to keep them as fields so that I can display them using WPF.

  • 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-06-11T23:58:01+00:00Added an answer on June 11, 2026 at 11:58 pm

    Your error is with class B. In class A you define D1 as public abstract D D1 { get; } However in B you are attempting to override D1 and add a setter — which is not defined by the abstract class. You’ll need to find another way to set the value in B. If other classes need to be able to set D1 then you may want to define D1 as public abstract D D1 { get; set; }

    If B only need to be able to set the value, just have it directly set the member value.

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

Sidebar

Related Questions

I'm running into an issue accessing a changed model field, traversing relationships in a
This is a design issue I keep running into, so I thought I would
I am running into a randomly occuring issue, and it looks like either there
I'm running into a strange issue in WebKit browsers, where the email field on
As a Rails newbie, I am running into an issue in which I can
I'm running into issues with the following code: var setupSearch = { searchSuggest: function(field)
I am currently running into an issue trying to create delegates from MethodInfo .
I'm running into an issue that's arising from the fact that one has to
I'm running into an issue where my deployment loops through Recycling. From Visual Studio:
I am running into an issue with the way my asynctasks are executed. Here's

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.