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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:44:49+00:00 2026-05-24T17:44:49+00:00

I am trying to strongly type an object property that has been defined as

  • 0

I am trying to strongly type an object property that has been defined as an interface in an interface. Here is my sample

// interfaces
public interface IMyInterfaceA
{
    string A { get; set; }
    IMyInterfaceB B { get; set; }
}

public interface IMyInterfaceB
{
    string B { get; set; }
}

// POCOs
public class pocoOneB : IMyInterfaceB
{
    public B { get; set; }
    public C { get; set; }  // extending the poco with a non-interfaced property
}

public class pocoOneA : IMyInterfaceA
{
    string A { get; set; }
    pocoOneB B { get; set; }  // fails, can I strongly type an interface??
}

public class pocoTwoB : IMyInterfaceB
{
    public B { get; set; }
    public D { get; set; }  // extending the poco with a non-interfaced property
}

public class pocoTwoA : IMyInterfaceA
{
    string A { get; set; }
    pocoTwoB B { get; set; } // fails, can I strongly type an interface??
}

The problem is I can’t do

pocoOneB B { get; set; } // fails, can I strongly type an interface??

or

pocoTwoB B { get; set; } // fails, can I strongly type an interface??

even though they are implementations of the interface, the compiler says I didn’t correctly implement IMyInterfaceA on either poco. I understand the error, however I would like to know if there is a way to strongly type a property that has an interface?

One way around this is to not have the interface IMyInterfaceA define a property of interface IMyInterfaceB at all and extent on the poco’s, however I am trying to enforce the property is implemented using interfaces.

The main reason I need to strongly type the properties of the poco is because I am using JSON to desterilize over the wire.

Thank you for any guidance.

  • 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-24T17:44:49+00:00Added an answer on May 24, 2026 at 5:44 pm
    public interface IMyInterfaceA<TPoco>
       where TPoco : IMyInterfaceB
    {     
       TPoco B { get; set; } 
    } 
    
    public class pocoOneA<TPoco> : IMyInterfaceA<TPoco>
      where TPoco : IMyInterfaceB
    {     
       public TPoco B { get; set; }  // fails, can I strongly type an interface?? 
    } 
    

    or simply

    public interface IMyInterfaceA
    {     
       IMyInterfaceB B { get; set; } 
    } 
    
    public class pocoOneA : IMyInterfaceA
    {     
       public IMyInterfaceB B { get; set; }  // fails, can I strongly type an interface?? 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add a strongly-typed view to the sample app that's created when
I'm working on a framework that I'm trying to type as strongly as I
I am trying to make a strongly typed viewstate object. public class MyNewPage :
I'm trying to create a strongly type html helper extension for a date picker
The DataContext.GetTable() method will return an object of type: System.Data.Linq.Table By doing that, I
I am trying to write an MVC webpage that has two drop down lists.
I have people object and poeple have property group that make them belong to
I am trying to design a table type structure that contains rows and cells.
I am trying to use reflection to collect a property from a class that
In a Silverlight 4 app I'm trying to instantiate an object whose type isn't

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.