Anyone care to comment on whether we should be using "I" or "II" and "&" or "&&" in our LINQ Where() extensions / queries? Any difference with LINQ to SQL? The resulting expression tree is more than I can get my brain around on a Friday afternoon
Thanks,
static void Main(string[] args)
{
var numbers = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
var q1 = numbers.Where(i => i == 1 | i == 2);
var q2 = numbers.Where(i => i == 1 || i == 2);
var q3 = numbers.Where(i => i == 1 & i < 3);
var q4 = numbers.Where(i => i == 1 && i < 3);
Write(q1);
Write(q2);
Write(q3);
Write(q4);
}
static void Write<T>(IEnumerable<T> t)
{
foreach (var i in t)
Console.Write("{0} ", i);
Console.WriteLine();
}
Results:
1 2
1 2
1
1
Press any key to continue . . .