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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:56:56+00:00 2026-05-10T19:56:56+00:00

Why was C# designed this way? As I understand it, an interface only describes

  • 0

Why was C# designed this way?

As I understand it, an interface only describes behaviour, and serves the purpose of describing a contractual obligation for classes implementing the interface that certain behaviour is implemented.

If classes wish to implement that behavour in a shared method, why shouldn’t they?

Here is an example of what I have in mind:

// These items will be displayed in a list on the screen. public interface IListItem {   string ScreenName();   ... }  public class Animal: IListItem {     // All animals will be called 'Animal'.     public static string ScreenName() {         return 'Animal';     } .... }  public class Person: IListItem {      private string name;      // All persons will be called by their individual names.     public string ScreenName() {         return name;     }      ....   } 
  • 1 1 Answer
  • 1 View
  • 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. 2026-05-10T19:56:57+00:00Added an answer on May 10, 2026 at 7:56 pm

    Assuming you are asking why you can’t do this:

    public interface IFoo {     void Bar(); }  public class Foo: IFoo {     public static void Bar() {} } 

    This doesn’t make sense to me, semantically. Methods specified on an interface should be there to specify the contract for interacting with an object. Static methods do not allow you to interact with an object – if you find yourself in the position where your implementation could be made static, you may need to ask yourself if that method really belongs in the interface.


    To implement your example, I would give Animal a const property, which would still allow it to be accessed from a static context, and return that value in the implementation.

    public class Animal: IListItem {     /* Can be tough to come up with a different, yet meaningful name!      * A different casing convention, like Java has, would help here.      */     public const string AnimalScreenName = 'Animal';     public string ScreenName(){ return AnimalScreenName; } } 

    For a more complicated situation, you could always declare another static method and delegate to that. In trying come up with an example, I couldn’t think of any reason you would do something non-trivial in both a static and instance context, so I’ll spare you a FooBar blob, and take it as an indication that it might not be a good idea.

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

Sidebar

Related Questions

I'm having trouble with the way I designed this little report I'm making. Is
I have two tables that I designed this way with a possible reshuffling of
I've read this question and I understand that its only possible to do it
I have designed this gui in netBeans which has a canvas , a couple
I have SQL Server 2008 with a table called ProductCategories designed like this: Id
is this proofed: every algorithm A designed using go to or something like, is
I have designed one sign-up form,in this form after getting all necessary values I
I initially designed my system following the s# architecture example outlined in this codeproject
My question is this: I have an application designed for iPhone and I decided
My website is designed to meet the accessibility guidelines. I'm HOPING that this means

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.