P
Peter Kirk
Hi
I have never used generics before, and I was wondering if the following sort
of use was acceptable/normal for a method:
public IList<IPerson> GetPersons()
{
IList<IPerson> personList = new List<IPerson>();
... // get the persons
return personList;
}
The meaning is that I return a "List" which holds only "IPerson" objects. In
earlier projects I have made without generics, I would have returned a
normal IList (eg ArrayList) or an array IPerson[].
Then I think the client should call it like:
IList<IPerson> persons = GetPersons();
Thanks,
Peter
I have never used generics before, and I was wondering if the following sort
of use was acceptable/normal for a method:
public IList<IPerson> GetPersons()
{
IList<IPerson> personList = new List<IPerson>();
... // get the persons
return personList;
}
The meaning is that I return a "List" which holds only "IPerson" objects. In
earlier projects I have made without generics, I would have returned a
normal IList (eg ArrayList) or an array IPerson[].
Then I think the client should call it like:
IList<IPerson> persons = GetPersons();
Thanks,
Peter