你知道我怎么升级我的项目来使用c# 6的特性吗?
我读到c# 6可以允许这样的新东西:
if (decimal.TryParse(txtPrice.Txt, out decimal price))
product.Price = price;
而不是:
decimal price;
if (decimal.TryParse(txtPrice.Txt, out price))
product.Price = price;
我想在我的项目中像使用c# 6的许多其他功能(新操作符?.
等)一样使用它。我目前正在做一个webform项目,但是当我写这个的时候:
Int32.TryParse(newValue.ToString().Trim(), out int intNumber)
或
Int32.TryParse(newValue.ToString().Trim(), out Int32 intNumber)
编译器不编译,它告诉我表达式不工作。
只要安装Roslyn最终用户预览版,假设你正在使用VS2013。请注意,链接目前不为我工作(无限期旋转),但是:这是来自Rosyln codeplex页面的链接
编辑:这是实际链接:https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=52793