【发布时间】:2020-04-01 08:34:24
【问题描述】:
我正在 VS2019 中创建新项目,目标是 .NET 4.7.1。 以下是我用于 out 参数内联声明的示例代码。
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
string a = "-1.5E5";
bool b = decimal.TryParse(a, out d number);
}
}
}
但是,编译器抱怨:
The type or namespace name 'd' could not be found (are you missing a using directive or an assembly reference?)
为了使用 C# 7 功能,除了指定目标 4.7 之外还有什么特别的吗?
【问题讨论】:
-
“out d number”中的d是什么?应该是“out var number”还是“out decimal number”?