Using LINQ expressions in Visual Studio's Watch window

I tried to reproduce your problem and found the following:

It seems the watch window uses the namespaces you referenced (via using) in your code.

If you don't use linq (and System.Linq namespace) in the code file, the watch window cannot find the extensions.

If you have a using System.Linq; and use something from that namespace in your code, the watch window will find and execute the linq extensions. (If you don't use anything from System.Linq the reference is optimized away, so this assembly is not loaded at runtime and the debugger can't use it).


If you don't have a 'using System.Linq' statement in the code, you can still use Linq queries by calling the extension methods manually:

System.Linq.Enumerable.Select(collection, x=>x.Name)

enter image description here

Try to add the following: (Its working on my test)

> using System.Collections.Generic;
 using System.Linq;