C# Querying With LINQ Now You're Querying Selecting, Projecting and Anonymous Types

Linq isn't working, is it supposed to be C#?

I'm learning using the Linq tool or library in C#. I don't like to use the workspace so I'm using my Visual Studio program.

In order to show results in the List-Array she types: from b in birds where b.Color == "Red" select b; that doesnt work in my C# Visual Studio. Only this worked: Console.WriteLine(from b in birds where b.Color == "Red" select b); but it doesnt show the array correctly

1 Answer

Steven Parker
Steven Parker
207,975 Points

It sounds like the instructor is evaluating the expression in the REPL, but you are compiling it into a program and using WriteLine to output the value. I'd guess the implicit formatting applied by the REPL is a bit different from what WriteLine does by default.

You may need to construct a loop to ouput the result, possibly applying some formatting manually to get a similar output.

Thank you, It helped me to understand this. Yeah I know, I always use a "foreach" to print the values.