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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:52:43+00:00 2026-05-26T13:52:43+00:00

I have 3 project : P1, P2 and P3 In P1, there is a

  • 0

I have 3 project : P1, P2 and P3

In P1, there is a definition of an Interface I

In P2, there is a Class C that implements Interface I

public class C : I
{
    ...
}

In P3, I have that method in a class:

public static C getC (int id)
{
   ...
}

At compile time, P3 does not compile because interface I is defined in a project that is not referenced. Why?

Note that I make no use of the interface in P3, I use the concrete class.

  • 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-26T13:52:44+00:00Added an answer on May 26, 2026 at 1:52 pm

    The reason is because the interface I is part of the public signature of C, thus when you use C it has to know about the interface definition as well. Thus it requires the assembly to be referenced.

    To illustrate:

    // Assembly 2
    public class C : I
    {
        ...
    }
    
    // Assembly 3 - needs definition of `I` from assembly 1 because part of `C`
    // public definition.
    public static C getC (int id)
    {
       ...
    }
    

    Because I is publicly visible as a part of C (for example, you can assign a C to a reference of type I, etc), assembly 3 that wants to use C needs both the definition of C (assembly 2) and I (assembly 1)

    However, if C used I internally (not visible to other assemblies), you wouldn’t need to reference I‘s assembly to use C. For example:

    // Assembly 2
    public class C 
    {
        private I _someInternalUseOfI = ...;
        ...
    }
    
    // Assembly 3 - Since in this case, `I` is only used privately in assembly 2,
    // only assembly 2 needs the reference to `I` in assembly 1.
    public static C getC (int id)
    {
       ...
    }
    

    Does that make sense? Because a class’s base classes and interfaces are part of its definition, they need to be known by any referencing assemblies. But if they are used internally but not visible externally, then they do not necessarily need to be known by any referencing assemblies.

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

Sidebar

Related Questions

I have a project that I am working on in django. There are a
In my project there is a class implementing an interface. The interface comes from
I have an Aspect with the following pointcut definition @Pointcut(execution(public de.company.project..* *(..))) and a
I have simple static lib in xcode with the only class test.h: @interface TestClass
I have a project where there are Windows, FreeBSD and Linux servers. I have
So I have a project where there is some automatic initialization going on through
I currently have the DatePicker in my project but there are problems due to
I have a project with a main MDI form. There is a child MDI
I have my project folder, for instance, myWeb . In it there are various
I have a mvc project and on one page there is a table of

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.