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.
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.
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)
{
}
the other answers showed you your syntax problem, but some tool (I think resharper) will warn you that you might enumerate the sequence more than once (maybe even VS - don't know because I use them together). If that is the problem write something like
var userArray = userList.ToArray();
and use userArray instead of userList
A foreach loop requires you to define a variable to place each iteration in. You have only defined the class and are missing the variable.
foreach(User _user in userList)
{
}