I have a IRepository and Repository that take in an anonymous type but it throws an error that it can't convert from List<T>
to List<T>
. The only reason I could think that this would happen is maybe T from IRepository and T from Repository is ambiguous.
public interface IRepository<T> where T : class
{
void DeserializeJSON<T>();
...
}
public class Repository<T> : IRepository<T> where T : class
{
private string data;
private List<T> entities;
public void DeserializeJSON<T>()
{
// Cannot implicitly convert type
entities = JsonConvert.DeserializeObject<List<T>>(data);
}
...
}