Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Help with foreach, getting 'possible multiple enumeration of IEnumerable'

Trying to do a foreach:

foreach(User in userList)
{

}

Where userList is a IEnumerable<User> userList

I tried doing: userList.ToList() but I get the same message.

like image 527
codecompleting Avatar asked Nov 30 '22 16:11

codecompleting


1 Answers

In your foreach statement, you haven't specified an identifier for the current instance of User. Try adding an identifier (e.g., currUser or just user) after the type User, like this:

foreach(User user in userList)
{

}
like image 67
Donut Avatar answered May 18 '23 16:05

Donut