Hello to all. There is a listbox . It is necessary to enter the data in the listbox . Why not that value is added.

Create an object

class1 s1 = new class1("exampleText"); 

Then I add an instance of the class to the list .

 List<class1> st = new List<class1>(); st.Add(s1); 

After that, application1.class1 is added to the listBox instead of "exampleText".

 listBox1.Items.Add(s1); 

    1 answer 1

    You will probably need to overload the ToString method in class1 and return the string value it needs. By default, being non-overloaded, this method returns the string name of the object class.

    How to: Override the ToString Method (C # Programming Guide)

    • excellent! - marioxxx