Please consider the following code:
class Student
{
}
enum StudentType
{
}
static void foo(IDictionary<StudentType, IList<Student>> students)
{
}
static void Main(string[] args)
{
Dictionary<StudentType, List<Student>> studentDict =
new Dictionary<StudentType, List<Student>>();
foo(studentDict);
...
}
There is the error:
error CS1503: Argument '1': cannot convert from 'System.Collections.Generic.Dictionary>' to 'System.Collections.Generic.IDictionary>'
Is there any way to call foo function?
static void foo(Dictionary<StudentType, List<Student>> students)
that will solve this problem as well. – Willettawillettestatic void foo(IDictionary<StudentType, IList<Student>> students)
is just for simplicity. Instead offoo()
the IDictionary<> is passed to another part of my application, so it is necessary to use theIDictionary<>
andIList<>
to provide an abstraction. – Panay