G
Guest
Hi,
I have a BindingList<T> collection and I am adding concrete object T in to
the binding list. Before adding them, I want to verify if object with same
data exist in the collection. When I use Binding list’s Contain method to
check if object exist in the collection, it always returns false. Is there a
way to achieve this? I have tried implementing IComparable interface on my
concrete class, but getting same result.
Code sample:
BindingList<User> uBL=new BindingList<User>();
User u=new User();
u.FirstName=â€TTTâ€;
u.LastName=â€CCCâ€;
if (! uBL.Contains(u)) //this always returns false
{
uBL.Add(u)
}
Public class User{
Public string FirstName=string.empty;
Public string LastName=string.empty;
Public User(){}
}
Thanks
Hiten
I have a BindingList<T> collection and I am adding concrete object T in to
the binding list. Before adding them, I want to verify if object with same
data exist in the collection. When I use Binding list’s Contain method to
check if object exist in the collection, it always returns false. Is there a
way to achieve this? I have tried implementing IComparable interface on my
concrete class, but getting same result.
Code sample:
BindingList<User> uBL=new BindingList<User>();
User u=new User();
u.FirstName=â€TTTâ€;
u.LastName=â€CCCâ€;
if (! uBL.Contains(u)) //this always returns false
{
uBL.Add(u)
}
Public class User{
Public string FirstName=string.empty;
Public string LastName=string.empty;
Public User(){}
}
Thanks
Hiten