IEnumerable<SelectListItem> error question
- by user281180
I have the following code, but i`m having error of
Error 6 foreach statement cannot operate on variables of type 'int' because 'int' does not contain a public definition for 'GetEnumerator' C:\Dev\DEV\Code\MvcUI\Models\MappingModel.cs 100 13 MvcUI
How can I solve this?
Note:
string [] projectID;
Class Employee
{
int id {get; set;}
string Name {get;set;}
}
public IEnumerable<SelectListItem> GetStudents()
{
List<SelectListItem> result = new List<SelectListItem>();
foreach (var id in Convert.ToInt32(projectID))
{
foreach( Employee emp in Project.Load(id))
result.Add(new SelectListItem
{
Selected = false,
Text = emp.ID.ToString(),
Value = emp.Name
});
return result.AsEnumerable();
}
}