Visual Studio 2015中的C#7.0``变量'' [英] C# 7.0 'out variables' in Visual Studio 2015
问题描述
我想在Visual Studio 2015中编译C#7.0解决方案,但出现语法错误:
I would like to compile C# 7.0 solution in Visual Studio 2015, but I have syntax error:
ErrorMessage:'DateTime'是一种类型,但用作变量.
ErrorMessage : 'DateTime' is a type but is used like a variable.
这与在C#7.0中更改的输出变量"有关
This is related to 'out variables' changed in C# 7.0
很遗憾,我无法使用VS2017(社区)和此教程-不起作用(master分支现在适用于VS2017).
Unfortunately I can not use VS2017 (community) and THIS TUTORIAL - not working (master branch is adapted to VS2017 now).
您有解决此问题的想法吗?
Do you have an idea how to solve this problem?
推荐答案
您只需要在调用外部声明一个DateTime
变量,并使用out
关键字传递参数,如下所示:
You just need to declare a DateTime
variable outside the call and pass the parameter with the out
keyword like this:
DateTime yuorParam;
method( ..., ..., out yourParam);
这篇关于Visual Studio 2015中的C#7.0``变量''的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!