# Is there a reason to inherit both generic and non-generic version of an interface? [closed]

I've just gotten into some C# programming and decided to expand my knowledge of how games are made in C# by looking through some open-source frameworks. While doing this I noticed something very odd; classes that they make would implement both generic and non-generic interfaces that represent the same data structure. For example:

public class SomeSpecialList<T> : IList<T>, IList {
...
}


I couldn't find any explanation to this - Is this something I should be thinking about when programming games in C#? Why? Is it a performance thing?

• – Bálint Jul 20 '17 at 15:13
• Generics weren't in version 1.1 of the .NET Framework, and a lot of APIs that have existed forever don't use them. Implementing both will make your code compatible with legacy code that doesn't use generics, including old framework code. If you don't need it, don't bother, but it doesn't cost anything to add. – error Jul 20 '17 at 15:18
• @error Backwards compatibility makes sense, I just figured since I saw it used in most of the game frameworks it may be related to something else that games might gain some extra benefit from (sorting, iteration speed, etc). But if that's not the case I should probably close this question since it turns out to have very little to do with game development. – Charanor Jul 20 '17 at 15:31

By implementing both IList and IList<T> you allow your type to have maximum (or at least, more) generality. Code that expects an IList (generally older code that predates the introduction of generics) can accept instances of your type.
• If I'm not mistaken, there are also some generic interfaces that require you implement non-generic versions, right? IEnumerable<T> requires implementing IEnumerable.GetEnumerator() if I recall correctly. – DMGregory Jul 20 '17 at 16:35