Cannot implicitly convert type 'System.Collections.IList' to 'System.Collections.Generic.List
This is my first attempt at generics and I'm a little puzzled. I don't understand what is causing this error. I've googled this and so far no light bulb going off. I've pointed out the line that causes the error but I can't seem to figure out why. I've included the functions related so you can get the overall picture to see what I'm doing. some insight would be appreciated. also being the first attempt at generics, I'm not sure if I'm doing this right, so feed back is welcomed.
The error
Cannot implicitly convert type 'System.Collections.IList' to 'System.Collections.Generic.List<Domains.Entities.Employee>'
Error point
this is the Load event of a form called debug
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
The method needs to return strong type generic list. (Thus Ilist or List will not return the desired List<Employee>)
Replace:
public System.Collections.IList Get_Data<T>(object objentity)
with
Thank you this solved it. I can't believe I over looked this, ...forest through the trees I guess.
Miguel Oz, I will be granting the answer to AndyAinscow, since his response was correct and the first. I made the change, removing System.Collections.IList and setting it to List<T>. then, resolved another unrelated error and it worked.
Thank you both for directing my focal point to this difference.
Steve7423
ASKER
Quick and accurate response. Thank you
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Replace:
public System.Collections.IList Get_Data<T>(object objentity)
with
Open in new window