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 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
  • 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. 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

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For a finite input, there is no formal regular expression… May 12, 2026 at 7:48 am
  • Editorial Team
    Editorial Team added an answer /^[^_]*$/ The [^] syntax means "do not include any of… May 12, 2026 at 7:48 am
  • Editorial Team
    Editorial Team added an answer Use a database. Mainly because what you expect and what… May 12, 2026 at 7:48 am

Related Questions

Inspired by this question I began wondering why the following examples are all illegal
I know this has been discussed many times, but I am not sure I
[Edit] My original-question was Why to decide between static and non-static? Both do the
Yesterday I ran into an Issue while developing a Web Part (This question is

Trending Tags

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

Top Members

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.