A
ADN
Hi, I have a method which calls my service factory:
class person
{
public int ID { get; set: }
public string Name {get; set;}
}
IList<Person> mypeople = __serviceFactory.Fetch(new Person())
Here is my generic method:
public List<T> Fetch<T>(T fetchobject)
{
Type __type = fetchobject.GetType();
// return a generic list of all of the people
IList<__type> myPeopleList = new IList<__type>();
myPeopleList = DataLayer.GetMyPeople(); // will return a
IList<Person>
return myPeopleList
}
I am getting an error when I try to cast the IList<type> because I
don't think you can do that. Is there a way I can pass in a generic
object and create a generic collection from a generic object?
class person
{
public int ID { get; set: }
public string Name {get; set;}
}
IList<Person> mypeople = __serviceFactory.Fetch(new Person())
Here is my generic method:
public List<T> Fetch<T>(T fetchobject)
{
Type __type = fetchobject.GetType();
// return a generic list of all of the people
IList<__type> myPeopleList = new IList<__type>();
myPeopleList = DataLayer.GetMyPeople(); // will return a
IList<Person>
return myPeopleList
}
I am getting an error when I try to cast the IList<type> because I
don't think you can do that. Is there a way I can pass in a generic
object and create a generic collection from a generic object?