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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:36:33+00:00 2026-05-12T18:36:33+00:00

Isn’t it much more elegant and neat to have an IStringable interface? Who needs

  • 0

Isn’t it much more elegant and neat to have an IStringable interface?

Who needs this Type.FullName object returned to us?

EDIT: everyone keeps asking why do I think it’s more elegant..

Well, it’s just like that, instead of IComparable, object would have CompareTo method, that by default throws an exception or returns 0.

There are objects that cannot and should not be described as a string. object could have equally returned string.Empty. Type.FullName is just an arbitrary choice..

And for methods such as Console.Write(object), I think it should be: Write(IStringable).

However, if you are using WriteLine to anything but strings (or something that its ToString is obvious such as numbers), it seems to me it’s for debugging mode only..

By the way – how should I comment to you all? Is it okay that I post an answer?

  • 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-12T18:36:33+00:00Added an answer on May 12, 2026 at 6:36 pm

    There are three virtual methods that IMHO should have never been added to System.Object…

    • ToString()
    • GetHashCode()
    • Equals()

    All of these could have been implemented as you suggest with an interface. Had they done so I think we’d be much better off. So why are these a problem? Let’s just focus on ToString():

    1. If ToString() is expected to be implemented by someone using ToString() and displaying the results you have an implicit contract that the compiler cannot enforce. You assume that ToString() is overloaded, but there is no way to force that to be the case.
    2. With an IStringable you would only need to add that to your generic type-constraint or derive your interface from it to require it’s usage on implementing objects.
    3. If the benefit you find in overloading ToString() is for the debugger, you should start using [System.Diagnostics.DebuggerDisplayAttribute].
    4. As for needing this implementation for converting objects to strings via String.Format(), and/or Console.WriteLine, they could have deferred to the System.Convert.ToString(object) and checked for something like ‘IStringable’, failing over to the type’s name if not implemented.
    5. As Christopher Estep points out, it’s culture specific.

    So I guess I stand alone here saying I hate System.Object and all of it’s virtual methods. But I do love C# as a whole and overall I think the designers did a great job.

    Note: If you intend to depend upon the behavior of ToString() being overloaded, I would suggest you go ahead and define your IStringable interface. Unfortunatly you’ll have to pick another name for the method if you really want to require it.

    more

    My coworkers and I were just speaking on the topic. I think another big problem with ToString() is answering the question “what is it used for?”. Is it Display text? Serialization text? Debugging text? Full type name?

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

Sidebar

Related Questions

This isn't a question that has a black/white yes/no answer, this is more a
This isn't much of a problem, really, it's entirely out of curiosity. For a
This isn't legal: public class MyBaseClass { public MyBaseClass() {} public MyBaseClass(object arg) {}
Why isn't Collection.remove(Object o) generic? Seems like Collection<E> could have boolean remove(E o); Then,
Isn't there a Design Pattern who describes how to high cohesion? I need some
Isn't visual studio supposed to automatically generate this file for each webservice creation ?
Isn't this / ? Why is there a constant for it? It's not like
Isn't Makefile syntax is target: require_files cmd... Why I got this problem? Makefile MXMLC
This isn't meant as a troll or flamebait or anything like that. I've been
Isn't every language compiled into low-level computer language? If so, shouldn't all languages have

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.