The project uses 2 components ( listBox , metroComboBox ), in which you need to record information. To do this, I use the UpdateListOfSports function, passing as an object either a listBox or a metroComboBox . When determining the type of object in the function itself, I encounter an error CS0173 , which I described below. I would be very grateful if you help solve this problem.
public void UpdateListOfSports(object obj) { DBConnect dbConnect = new DBConnect(); DataTable dt = dbConnect.SelectValues("SELECT * FROM sport"); var list = (obj is ListBox) ? (ListBox)obj : (MetroComboBox)obj; // тут ошибка list.Items.Clear(); foreach (DataRow row in dt.Rows) list.Items.Add(row["KindOfSport"].ToString()); list.SelectedIndex = 0; } Error CS0173 Cannot determine the type of conditional expression because the implicit conversion between
System.Windows.Forms.ListBoxandMetroFramework.Controls.MetroComboBoxdoes not exist.
list? - VladD