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

  • Home
  • SEARCH
  • 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 752815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:49:32+00:00 2026-05-14T14:49:32+00:00

I am getting this error while creating a public method on a class for

  • 0

I am getting this error while creating a public method on a class for explicitly implementing the interface. I have a workaround: by removing the explicit implementation of PrintName method. But I am surprised why I am getting this error.

Can anyone explain the error?

Code for Library:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Test.Lib1
{

    public class Customer : i1 
    {
        public string i1.PrintName() //Error Here...
        {
            return this.GetType().Name + " called from interface i1";
        }
    }

    public interface i1
    {
        string PrintName();
    }

    interface i2
    {
        string PrintName();
    }
}

Code for Console Test Application:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Test.Lib1;

namespace ca1.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Customer customer = new Customer();
            Console.WriteLine(customer.PrintName());

            //i1 i1o = new Customer();
            //Console.WriteLine(i1o.printname());

            //i2 i2o = new Customer();
            //Console.WriteLine(i2o.printname());

        }
    }
}
  • 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-14T14:49:32+00:00Added an answer on May 14, 2026 at 2:49 pm

    When using explicit implementation of an interface, the members are forced to something more restricted than private in the class itself. And when the access modifier is forced, you may not add one.

    Likewise, in the interface itself, all members are public. If you try to add a modifier inside an interface you will get a similar error.

    Why are explicit members (very) private? Consider:

    interface I1 { void M(); }
    interface I2 { void M(); }
    
    class C : I1, I2
    {
        void I1.M() { ... }
        void I2.M() { ... }
    }
    
    C c = new C();
    c.M();         // Error, otherwise: which one?
    (c as I1).M(); // Ok, no ambiguity. 
    

    If those methods were public, you would have a name-clash that cannot be resolved by the normal overload rules.

    For the same reason you cannot even call M() from inside a class C member. You will have to cast this to a specific interface first to avoid the same ambiguity.

    class C : I1, I2
    {
       ...
       void X() 
       {  
         M();             // error, which one? 
         ((I1)this).M();  // OK 
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 497k
  • Answers 497k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Static members are not inherited, although it's confusingly possible to… May 16, 2026 at 11:57 am
  • Editorial Team
    Editorial Team added an answer I would do something like this: XML: <TestResult> <set-value idref="account_lockout_duration_var">900</set-value>… May 16, 2026 at 11:57 am
  • Editorial Team
    Editorial Team added an answer Just updated to the latest UI CSS and worked like… May 16, 2026 at 11:57 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm creating a simple code generator with delegates. Why am I getting this error
I'm getting this error (see title) while trying to parse an XML file in
While developing with Firebug I keep getting this error. pages[x].css(z-index,x) is not a function
While deploying a dwr web app, i'm continuously getting this error. I dont know
I am getting the following error while running my MVC application, which uses the
After resolving issues with RIA installation here , I'm still getting this following error.
I'm getting the following error when I connect my Silverlight app to my WCF
This is my SimpleDBAdapter Class that encapsulates all the complexities of accessing the database
I have installed Visual Studio 2010 and Silverlight 4 tools. Still, i am getting
I am creating a named pipe using JNI by calling the mkfifo() command. I

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.