How do I convert a non-Generic IList to IList?

If you’re sure that all of the elements inherit from T (or whatever type you’re using)

IList<T> myList = nonGenericList.Cast<T>().ToList();

If you’re not sure:

IList<T> myList = nonGenericList.OfType<T>().ToList();

Of course, you will need the System.Linq namespace:

using System.Linq;

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)