Background
When working with frames in the process, I write the Code "T=>t.x.equals" (model) when I encounter the criteria for writing LINQ. ID) &t.y.equals (model. Name) "is similar to this form. But the results of the program error. Then I wrote the following code.
Code 1
1 class Program2 {3 Static voidMain (string[] args)4 {5 varPersons =getpersonlist ();6 varresult = persons. Where (U = u.age = =2&u.name=="B");7 foreach(varIteminchresult)8 {9 Console.WriteLine (item. ToString ());Ten } One Console.readkey (); A } - - Private StaticList<person>getpersonlist () the { - return NewList<person> - { - Newperson {Name ="A", age =1}, + Newperson {Name ="B", age =2}, - Newperson {Name ="C", age =2} + }; A } at } - - Public class Person - { - Public stringName {Get;Set; } - in Public intAge {Get;Set; } - to Public Override stringToString () + { - return string. Format ("Name:{0},age:{1}", Name, age); the } *}
Run results
Code 2
1 Static voidMain (string[] args)2 {3 varPersons =getpersonlist ();4 varresult = persons. Where (U = u.age = =2&&u.name=="B");5 foreach(varIteminchresult)6 {7 Console.WriteLine (item. ToString ());8 }9 Console.readkey ();Ten}
In the original & Add a &, the same program can also run, the results are also
Questions
The ienumerable<t> extension method inside C # is the same as the bitwise operator (&) and the operator (&&)?
Talk about the difference between & and && in the judgment expression in the c#ienumerable<t> extension method?