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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:38:05+00:00 2026-06-09T16:38:05+00:00

I have interfaces IChild and IParent . IParent has a member that is a

  • 0

I have interfaces IChild and IParent. IParent has a member that is a List<IChild>.

I wish to have classes that implement IParent where each class has a member that implements IChild:

public interface IChild
{ 
}  

public interface IParent
{  
    List<IChild> a { get; set; }
} 

public class ChildA : IChild
{ 
} 

public class ChildB : IChild
{ 
} 

public class ParentA : IParent
{ 
    public List<ChildA> a { get; set; }
}

public class ParentB : IParent
{ 
    public List<ChildB> a { get; set; }
}

But, this code will not compile. The error is:

`MyApp.Data.ParentA` does not implement interface member `MyApp.Data.IParent.a`.
`MyApp.Data.ParentA.a` cannot implement `MyApp.Data.IParent.a` because it does not have
the matching return type of `System.Collections.Generic.List<MyApp.Data.IChild>`.
  • 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-09T16:38:06+00:00Added an answer on June 9, 2026 at 4:38 pm

    Make IParent generic:

    public interface IChild
    {
    }
    
    public interface IParent<TChild> where TChild : IChild
    {
        List<TChild> a { get; set; } 
    }
    
    public class ChildA : IChild {  }   
    
    public class ChildB : IChild {  }   
    
    public class ParentA : IParent<ChildA>
    {
        public List<ChildA> a { get; set; }
    }
    
    public class ParentB : IParent<ChildB>
    {
        public List<ChildB> a { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 interfaces and 2 classes that I investigate via Reflection: IParent IChild
I have defined classes: public class Parent : IParent { public string ParentText {
If we have a class that inherits from multiple interfaces, and the interfaces have
I have multiple interfaces that my objects can implement. I am wondering if there
Sometimes I wonder that we do have interfaces and abstract classes for two different
I have following interfaces public interface IReport<TInput, TOutput> { List<TOutput> GenerateReport(TInput input); } public
I have X interfaces to Y computers that communicate over a public network (Think
Let's say I have 2 interfaces, A and B: public interface A { List<B>
I have several interfaces and classes that I have in my business layer project
I have two interfaces IHeaderRow , and IDetailRow I then have an object that

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.