I saw a piece of code which was written like this:
if (from n in numbers select n where n = 5)
However, I tried writing something like this but came across errors (bare in mind the code sample may not be exactly as above as I am typing from memory). How can I write code like the above?
Thanks
In order to use this as a condition, you need to have an expression that returns a boolean. Most likely, this means checking to see if there are any numbers that meet your criteria.
You probably wanted to do:
Personally, I’d avoid the language integrated syntax, and write this as:
Or even: