This has nothing to do with 'var'. Var is just a feature which allows you to not have to type the type when declaring a variable.
It has more to do with the inner-workings of LINQ. You should understand that your variable tempList is not holding a List or Collection, but rather an expression.
Each time you do an operation on 'tempList' (like calling Count() or iterating over it), the expression will be evaluated again.
this:
var tempList = SPList.Where(x=>x.Status==1);
int counter = tempList.Count();
will behave totally different than this:
var tempList = SPList.Where(x=>x.Status==1).ToList();
int counter = tempList.Count();
In the second code-sample, the variable 'tempList' really contains a List, whereas in the first code-sample, the variable tempList contains an expression.
When you add a new object to SPList
, and call Count() on tempList again, the new item will be included in the count in the first code-example, whereas in the second code-sample it will not be included. (Since in the 2nd sample, tempList is now a separete list, whereas in the first sample, the expression that counts the items in SPList is executed again).