G
Guest
Hi,
I would like to have something like that :
IList<IUser> list2 = list1 as IList<IUser>;
where list1 is a generic collection of User ( IList list1<User>=new
List<User>() ) and where User implement the interface IUser.
But this did not work...
I thought that as User implement IUser it was possible to cast the generic
collection between the two types. Currently I ve to use a foreach loop to
populate the list2 collection :
foreach(User u in list1)
{
list2.add(u as IUser);
}
Is there a more efficient and elegant way for doing this ?
Thanks.
Yalt.
I would like to have something like that :
IList<IUser> list2 = list1 as IList<IUser>;
where list1 is a generic collection of User ( IList list1<User>=new
List<User>() ) and where User implement the interface IUser.
But this did not work...
I thought that as User implement IUser it was possible to cast the generic
collection between the two types. Currently I ve to use a foreach loop to
populate the list2 collection :
foreach(User u in list1)
{
list2.add(u as IUser);
}
Is there a more efficient and elegant way for doing this ?
Thanks.
Yalt.