Which one of these is the faster/better one?
This one:
List list = new List();
User u;
foreach (string s in l)
{
u = new
In this scenario, the second version is better.
In general, if you only need to access the value within the body of the iteration, then choose the second version. On the other hand, if there is some final state the variable will hold beyond the body of the loop, then declare then use the first version.