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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:00:17+00:00 2026-05-22T13:00:17+00:00

Q1 Why do new classes from .NET implement interfaces only partially? Q2 Shall I

  • 0

Q1 Why do new classes from .NET implement interfaces only partially?

Q2 Shall I do the same in my code?

I asked this question here, so I thought, okay that was long time ago, you can have different usage etc etc, and now such implementation is supported only for consistency reasons. But new classes also do that.

Old

int[] list = new int[] {};
IList iList = (IList)list;
ilist.Add(1); //exception here

New

ICollection c = new ConcurrentQueue<int>();
var root = c.SyncRoot; //exception here

UPDATE

I am not worried why I get exceptions, it is clear. But I don’t understand why classes implement the well defined contract, but not all the members (which can lead to unpleasant run time exceptions)?

  • 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-22T13:00:18+00:00Added an answer on May 22, 2026 at 1:00 pm

    You could argue that the interfaces weren’t granular enough in the original design. For example, most people never use SyncRoot – it could perhaps have been on a different interface. Likewise, it is unfortunate that no interface offers read-only indexer access, for example.

    As it stands, the interfaces are what they are. It is still very convenient to implement the main IList[<T>]/ICollection[<T>]/IEnumerable[<T>] interfaces though – it offers the majority of callers access to what they need… so indexers in the first example, and Add in the second.

    To be fair, they do also offer IsFixedSize and IsReadOnly – querying the first would have led you to not call Add. Re SyncRoot – that presumably can’t make sense inside ConcurrentQueue<T>, and any implementation would break the logic of the type. Normally I would say “then it isn’t that type; don’t implement the interface”, but to repeat my earlier statement… most people never use SyncRoot – so I’m OK with it ;p

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

Sidebar

Related Questions

I'm currently adding some new extended classes to this code: foreach (BaseType b in
I'm using the ConcurrentDictionary and ConcurrentQueue classes from .NET 4 in the following code.
When adding new properties to classes, I find myself typing the same things over
(This question specifically in C#, but applies generally to .NET) I have a largish
How would you design an application (classes, interfaces in class library) in .NET when
Apologies, I'm new to ASP.NET MVC. :) I'm unsure if this is simple a
I'm writing a .NET 3.5 application (WinForms) which uses classes from an external DLL
Please bear with me, I come from .net and am new to the java
Why does Visual Studio declare new classes as private in C#? I almost always
It seems to me that explicitly specifying serialVersionUID for new classes is bad. Consider

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.