I'm wanting to fill a comboBox with a series of Matters but I do not want it to be repeated. What I do is go through courses already filtered for the student that contain a subject id.
listaCursos = curlog.GetAllFiltrados();
foreach (Curso c in listaCursos)
{
Materia = matlog.GetOne(c.IDMateria);
if (idPlan == Materia.IdPlan)
{
if (!materiasFiltradas.Contains(Materia))//ACA ESTA EL PROBLEMA
{
materiasFiltradas.Add(Materia);
}
}
}
I bring the Matter, I notice if they are of the student's plan and I add it to a list. The problem appears when I want to see if the matter is already in the list, because the Contains method works with the reference to the instance of the object and not the content, so even if the matter is the same, it does not take it as the same. How can I do so that I do not add the same subject twice? Thanks!