private static readonly List<List<T>> data = new List<List<T>>();
private static void ProcessData(IEnumerable<IEnumerable<T>> data) { }
private static void ProcessData(IEnumerable<IList<T>> data) { }
private static void ProcessData(IList<IEnumerable<T>> data) { }
private static void ProcessData(IList<IList<T>> data) { }
static void Main(string[] args)
{
ProcessData(data);
}
- Which overload is called?
- Why?
- How to call the other ones without explicit cast?
>` (cannot convert). So 3 and 4 are out which leaves 1 and 2. Overloading goes by "best" fit, and since `IList` is a better fit then `IEnumerable` it ends up choosing 2.
– Nov 08 '19 at 10:45