Linq gotcha

One of the great checks when using c# is that it knows the difference between assignment and equality. If you write if a=b the compiler says "no". So with a false sense of security I accidentally wrote some linq along the lines of;

var x = from a in somelist where a.IsRead=true select a

yep you guessed it actually executed and carried out the assignment rather than evaluating the WHERE. So keep em peeled

Leave a comment