2 ms·
I was annoyed by it back when I was doing Silverlight/ASP.NET Thing was a lot of Microsoft APIs for GUIs and whatnot used the List and if you wanted to use the
by PaulHoule 4mo ago
I was annoyed by it back when I was doing Silverlight/ASP.NET
Thing was a lot of Microsoft APIs for GUIs and whatnot used the List and if you wanted to use the List<X> you had to copy the list or make a wrapper or something. You might say, "just use the List" but at that point (circa 2008) I had to also use the List<X> for some API so I always had to do some conversion.
- cindyllm 4mo ago[dead]
- int_19h 4mo agoThe way it worked in practice is that all the new built-in collections in System.Collections.Generic implemented the non-generic interfaces as well, so e.g. List<T> implements IList<T>, but it also implements IList (explicitly), and similarly for ICollection and IEnumerable. Then, when WinForms or WPF wanted a list, you could just give it a List<T> instance, and it would talk to it via IList, boxing and unboxing if necessary. What you describe happened in the other direction - if you had, say, a generic method operating on IEnumerable<T> or IList<T>, and wanted to pass it a WinForms collection. WinForms generally defined strongly typed collection classes on a case by case basis, but none of them implemented the new interfaces. It was there where you had to wrap things, most often using AsEnumerable<T>().