I have an interface:
public interface IMyInterface { }
I have a class which implements the interface:
public class MyClass : IMyInterface { }
I have a function which asks for an IEnumerable of IMyInterface:
private void TestFunction(IEnumerable<IMyInterface> collectie) { }
I can't figure out why this doesn't work:
ObservableCollection<MyClass> myClasses = new ObservableCollection<MyClass>();
TestFunction(myClasses); // this line doesn't work
An ObservableCollection is an IEnumerable, right?
And my class does implement, right?
So why doesn't this work?
It gives this 2 errors:
Error 1 The best overloaded method match for 'WindowsFormsApplication1.Form1.TestFunction(System.Collections.Generic.IEnumerable)' has some invalid arguments C:\spike\spike_rtf\WindowsFormsApplication1\Form1.cs 59 4 WindowsFormsApplication1 Error 2 Argument '1': cannot convert from 'System.Collections.ObjectModel.ObservableCollection' to 'System.Collections.Generic.IEnumerable' C:\spike\spike_rtf\WindowsFormsApplication1\Form1.cs 59 17 WindowsFormsApplication1