I need to be able to loop around an unknown type for example
foreach (var test in viewData["foobar"])
{
}
Any suggestions
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You have to at least cast
viewData["foobar"]toIEnumerableto haveobjects in yourtestvariable.The cast may fail, so you’ll first have to check whether
viewData["foobar"]actually implementsIEnumerablewithisorasoperator:Note that this is using
System.Collections.IEnumerable, notSystem.Collections.Generic.IEnumerable<>.