F
Fred Chateau
I have three classes. Among other properties, these classes contain the
following lists:
----
public class QuestionsForm
{
public IList<SubCategories> SubCategoriesList { get; set; }
}
public class SubCategories
{
public IList<Questions> QuestionsList { get; set; }
}
public class Questions
{
public IList<ResponseOptions> ResponseOptionsList { get; set; }
}
----
QuestionsForm questionsForm = new QuestionsForm();
questionsForm.SubCategoriesList = new List<SubCategories>();
foreach (var subCategory in subCategories)
{
questionsForm.SubCategoriesList.Add(subCategory);
List<Questions> questionsList = new List<Questions>();
foreach (var question in questions)
{
questionsList.Add(question);
}
questionsForm.SubCategoriesList.Add(questionsList);
<--- Error
}
}
----
Error: Argument type "List<Questions>" is not assignable to parameter type
"SubCategories".
----
Would someone tell me how to handle this properly?
Regards,
Fred Chateau
following lists:
----
public class QuestionsForm
{
public IList<SubCategories> SubCategoriesList { get; set; }
}
public class SubCategories
{
public IList<Questions> QuestionsList { get; set; }
}
public class Questions
{
public IList<ResponseOptions> ResponseOptionsList { get; set; }
}
----
QuestionsForm questionsForm = new QuestionsForm();
questionsForm.SubCategoriesList = new List<SubCategories>();
foreach (var subCategory in subCategories)
{
questionsForm.SubCategoriesList.Add(subCategory);
List<Questions> questionsList = new List<Questions>();
foreach (var question in questions)
{
questionsList.Add(question);
}
questionsForm.SubCategoriesList.Add(questionsList);
<--- Error
}
}
----
Error: Argument type "List<Questions>" is not assignable to parameter type
"SubCategories".
----
Would someone tell me how to handle this properly?
Regards,
Fred Chateau