I have a defined class which I want to take two methods toString (), especially for the aesthetics of the program, I want in one case to display several variables (for a listbox) and for another only one variable (for a combobox) , in the following way.
Or in what way would be better, especially because I add the object as such to the components (listbox and combobox).
public class ZonaSistema
{
//Declaración de atributos
private int idZona;
private int numeroZona;
private string descripcionZona;
private int particionZona;
//Sobrecarga al método toString
public override string ToString()
{
return "Zona: " + this.numeroZona + "\tDescripción: " + this.descripcionZona + "\tPartición: " + this.particionZona;
}
public override string ToString()
{
return "Zona: " + this.numeroZona;
}
}