© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•11mo ago•
40 replies
Jasonnn

Nongeneric interfaces and collection classes

In "C#12 In A Nutshell", they say:
"As with the interfaces we discussed previously, you usually have a choice of generic or nongeneric versions of each type. In terms of flexibility and performance, the generic classes win, making their nongeneric counterparts redundant except for backward compatibility. This differs from the situation with collection interfaces, for which the nongeneric versions are still occasionally useful."
But the only example they gave was for type unification (since you can't cast IEnumerable<int> to IEnumerable<object> for example). Why is that that type unification is useful just for interfaces and not for collection classes themselves? As far as I understand you can't cast int[] to object[] either.

Do you have scenarios in mind for which Nongeneric interfaces are useful and nongeneric collection classes are not?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Issues with interfaces and generic classes
C#CC# / help
3y ago
❔ C# abstract classes & interfaces
C#CC# / help
3y ago
Collection of different classes
C#CC# / help
4y ago