IEnumerable<SelectListItem> error question
Posted
by user281180
on Stack Overflow
See other posts from Stack Overflow
or by user281180
Published on 2010-03-26T09:52:07Z
Indexed on
2010/03/26
9:53 UTC
Read the original article
Hit count: 123
c#
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();
}
}
© Stack Overflow or respective owner