I have two objects: User and Client, both implement the IMember interface
interface IMember
{
int Id { get; set; }
string Name { get; set; }
}
In the form, I set the ListBox data source:
myListBox.DisplayMember = "Name";
myListBox.ValueMember = "Id";
myListBox.DataSource = membersList; // List<IMember>
And weirder things come up;) When I run the program, the first object that is of type User is displayed correctly (Adrian Serafin) and other objects that are of type Contact are displayed as follows:
MyProject.Client#20
MyProject.Client#40
since there was a call toString () to display.
I can not use a list of different objects that implement the same interface as the data source in the ListBox, or did I make some mistake here?
source
share