Consider the following code:
namespace TestNameSpace {
public interface IFinder
{
IEnumerable<T> GetData<T>(DataStore dataStore);
}
public class EmployeeFinder : IFinder {
public IEnumerable<Employee> GetData<Employee>(DataStore dataStore) {
return dataStore.Employees; //*****This causes an error*****
}
}
public class DataStore {
public IEnumerable<Employee> Employees { get; set;}
}
public class Employee {
}
}
The line where I return dataStore.Employees causes a compilation error.
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<TestNameSpace.Employee>' to 'System.Collections.Generic.IEnumerable<Employee>'. An explicit conversion exists (are you missing a cast?)
Why is an implicit conversion required when they are the same type? Why is one namespaced while the other isn't?
Thanks!
Employee) in different namespaces. Look through your codebase for missing namespace declarations or accidentally redefined classes. - Asad Saeeduddin