c# - Visual Studio 2015 Convert.ToDouble 在尝试观看 lambda 表达式时出错

标签 c# lambda visual-studio-2015 visual-studio-debugging

我正在尝试 VS 2015,众所周知,最酷的功能之一是能够在监 window 口中监视 lambda 表达式。

我创建了一个控制台应用程序来测试它,这里是它的代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WatchLambdaExpressions
{
    class Program
    {
        static void Main(string[] args)
        {
            var books = new List<Book>() {new Book()
            {
                Author="J.K.Rowling",
                Rating="5",
                Title="Harry Potter"
            },
            new Book()
            {
                Author="Baroness Orczy",
                Rating = "4.8",
                Title="Scarlet Pimpernell"
            },
            new Book()
            {
                Author = "J.R.R.Tolkein",
                Rating="5",
                Title="Lord of the Rings"
            },
            new Book()
            {
                Author="Alexander Dumas",
                Rating="4.9",
                Title="Count of Monte Cristo"
            },
            new Book()
            {
                Author="Robert Ludlum",
                Title = "Bourne Identity",
                Rating = "4.6"
            }
            };

            var selectedBooks = books.Where(b => Convert.ToDouble(b.Rating) >= 4.8);

        }
    }

    public class Book
    {
        public string Title { get; set; }

        public string Author { get; set; }

        public string Rating { get; set; }
    }
}

我在 Debug模式下运行程序,并在 Main 方法的退出点处设置了一个断点。

好的,现在我去监 window 口写:

books.Where(b => Convert.ToDouble(b.Rating) >= 4.8)

我希望上面的内容能够评估和过滤并向我显示 rating >= 4.8 的书籍列表,但它显示了

Error: The debugger is unable to evaluate this expression

你知道为什么吗?

不过我可以观察其他 lambda 表达式。

这很好用:

books.Where(b => b.Title.Contains("Harry"))

最佳答案

Visual Studio 2015 Update 1 hs 修复了这个问题。所以我认为这已经解决了。谢谢

关于c# - Visual Studio 2015 Convert.ToDouble 在尝试观看 lambda 表达式时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31890131/

相关文章:

C# 对象创建比构造函数调用慢得多

java - 如何在 Stream.collect 中为 HashMap 使用双冒号?

c# - 使用 System.Data.SQLite 和 Entity Framework 6 的简单示例

visual-studio-2015 - 使用 WebJob 发布简单的 Asp.Net Core App (.Net Framework)

c# - 如何从 Visual Studio 2012 项目降级到 Visual Studio 2008

c# - 为什么我在从 .net core rc1 迁移到 rc2 时遇到这种不兼容问题

python - 折叠 and (lambda s : "". join(s.split())) 或 (lambda s: s)

node.js - 当从源代码管理下载更新的 package.json 时,是否可以使 Visual Studio 调用 npm install ?

c# - 在 C# 中使用 Func<T> 的多态性

python - 为什么 lambda 函数中的括号会导致 Python 3 上的语法错误?