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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:53:30+00:00 2026-05-14T15:53:30+00:00

Is it possible in C# to have a class that implement an interface that

  • 0

Is it possible in C# to have a class that implement an interface that has 10 methods declared but implementing only 5 methods i.e defining only 5 methods of that interface??? Actually I have an interface that is implemented by 3 class and not all the methods are used by all the class so if I could exclude any method???

I have a need for this. It might sound as a bad design but it’s not hopefully.
The thing is I have a collection of User Controls that needs to have common property and based on that only I am displaying them at run time. As it’s dynamic I need to manage them for that I’m having Properties. Some Properties are needed by few class and not by all. And as the control increases this Properties might be increasing so as needed by one control I need to have in all without any use. just the dummy methods. For the same I thought if there is a way to avoid those methods in rest of the class it would be great. It sounds that there is no way other than having either the abstract class or dummy functions 🙁

  • 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-14T15:53:30+00:00Added an answer on May 14, 2026 at 3:53 pm

    You can make it an abstract class and add the methods you don’t want to implement as abstract methods.

    In other words:

    public interface IMyInterface
    {
        void SomeMethod();
        void SomeOtherMethod();
    }
    
    public abstract class MyClass : IMyInterface
    {
        // Really implementing this
        public void SomeMethod()
        {
            // ...
        }
    
        // Derived class must implement this
        public abstract void SomeOtherMethod();
    }
    

    If these classes all need to be concrete, not abstract, then you’ll have to throw a NotImplementedException/NotSupportedException from inside the methods. But a much better idea would be to split up the interface so that implementing classes don’t have to do this.

    Keep in mind that classes can implement multiple interfaces, so if some classes have some of the functionality but not all, then you want to have more granular interfaces:

    public interface IFoo
    {
        void FooMethod();
    }
    
    public interface IBar()
    {
        void BarMethod();
    }
    
    public class SmallClass : IFoo
    {
        public void FooMethod() { ... }
    }
    
    public class BigClass : IFoo, IBar
    {
        public void FooMethod() { ... }
        public void BarMethod() { ... }
    }
    

    This is probably the design you really should have.

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

Sidebar

Related Questions

I have a class that implements an Interface with some methods. I also have
Possible Duplicate: How to Deserialize XML document Suppose that I have a class that
Possible Duplicate: Circular (or cyclic) imports in Python I have class B that imports
In PHP, is it possible to have a function within a class that's non-static,
Is it possible to have multiple classes that inherit/extends same class in Google AppEngine
I have noticed that it is possible to define a custom class and then
I have been lead to believe that it is possible to pass a class
Possible Duplicate: Difference between Color.red and Color.RED I have seen that the Java class
I want to implement a class in c++ that has a callback. So I
I have an java interface which has few abstract methods. public interface Interface {

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.