lambda expressions in immediate window for VS2015
This definitely works for me, looks like when I tick either Use Managed Compatibility Mode
or Use the legacy C# and VB expression evaluators
it stops working. Ensure those are unchecked.
Expression cannot contain lambda expression -Visual Studio 2015
Not sure about new feature in VS2015
but try setting the expression to a variable and then debug like
var data = lstClientDBs.Select(obj=>obj.ClientDatabase);
Strange but looks like MS declares that they have added that feature in VS2015 debugger
(https://devblogs.microsoft.com/devops/support-for-debugging-lambda-expressions-with-visual-studio-2015/)
Also, you probably meant to use a Where()
extension method than Select()
like
var data = lstClientDBs.Where(obj=>obj.ClientDatabase);
Visual Studio Immediate Window - Lambda Expressions Aren't Allowed - Is there a Work-around or Alternative?
At times like this I always turn to the most excellent LINQPad.
The front page of the linked site (at time of writing) immediately jumps in with stuff about SQL but don't let that obscure how powerful and flexible this tool really is. I sort of treat it like an Immediate Window on steroids. I find it invaluable for working my way through complex LINQ queries.
If you can live without intellisense it's free (the intellisense version is chargeable).
Why can't I use lambda expressions in the Immediate Window?
Jaredpar explained it
Why is LINQ absent from debugger windows?
Why is LINQ absent from debugger windows (Part 2)?
Visual Studio debugging quick watch tool and lambda expressions
Lambda expressions, like anonymous methods, are actually very complex beasts. Even if we rule out Expression
(.NET 3.5), that still leaves a lot of complexity, not least being captured variables, which fundamentally re-structure the code that uses them (what you think of as variables become fields on compiler-generated classes), with a bit of smoke and mirrors.
As such, I'm not in the least surprised that you can't use them idly - there is a lot of compiler work (and type generation behind the scenes) that supports this magic.
Expression not supported when debugging lambda expressions
After running several tests (no post/article on this topic found as a reference), I came to verdict that debugging of Lambda expressions does not work on Xamarin with Xamarin debugger.
Same code/expression does normally work on standard application:
This seems to be unrelated to version of .NET, as downgrading to version 4.0 (on Console app), still provide same debug results.
I have noted that in properties of Android project, there is an option called "debugger" and values to choose from: Xamarin, Microsoft Standard debug of Console app is most likely with the Microsoft one - which might have full support of debugging the Lambda expression.
Related Topics
Monitoring Garbage Collector in C#
How to Center Your Main Window in Wpf
How to Define Multiple Names for Xmlelement Field
Benefits of Using Async and Await Keywords
C#: Detecting Which Application Has Focus
Sqlexception:String or Binary Data Would Be Truncated
Asynchronous Iterator Task<Ienumerable<T>>
How to Programmatically Change Printer Settings with the Webbrowser Control
How to Display the String HTML Contents into Webbrowser Control
Are Ienumerable Linq Methods Thread-Safe
Resharper Complains When Method Can Be Static, But Isn'T
How to Check If Another Instance of the Application Is Running
Variable Declarations Following If Statements
The Connection Was Not Closed the Connection's Current State Is Open
Why Is This Process Crashing as Soon as It Is Launched