public void ClassifyControlTypes(List <Control> controls) { tableEntities.Clear(); joinEntities.Clear(); foreach (Control c in controls) { if (c.GetType() == typeof(TableControl)) { TableControl tc = (TableControl)c; tableEntities.Add(tc.GetTableEntity()); } else if (c.GetType() == typeof(JoinControl)) { JoinControl jc = (JoinControl)c; joinEntities.Add(jc.GetJoinEntity()); } } }