我正在尝试 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/