gpt4 book ai didi

c# - out var,当前上下文中不存在名称 'var'

转载 作者:行者123 更新时间:2023-11-30 23:01:45 25 4
gpt4 key购买 nike

我有以下错误:

The name 'var' does not exist in the current context

在这个方法调用上:

myClient.GetCurrentPadding(out var currentPadding);

可能是什么问题?我已尝试更新 microsoft.net.compilers nugget 但徒劳无功

最佳答案

out var 是正确的,如果您至少使用 C# 7.0,则可用。

这是文档中关于名为 out variables 的功能的描述.

因此,您需要按照本 link 中的解释,确保您的项目配置为至少使用 C# 7 功能。 .

这是链接解释的内容:

Right-click on the project node in Solution Explorer and select Properties. Select the Build tab and select the Advanced button. In the dropdown, select the version. The following image shows the "latest" setting:

enter image description here

关于c# - out var,当前上下文中不存在名称 'var',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50857780/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com