error CS8773: "Feature 'global using directive' is not available in C# 9.0" after downgrade from net6.0 to net5.0

error CS8773: "Feature 'global using directive' is not available in C# 9.0" after downgrade from net6.0 to net5.0

回答1

remove <ImplicitUsings>enable</ImplicitUsings> in the csproj project file, then can build success

find this solution from here

回答2

Remove the tag indeed work.
But just change the value of it did the trick as well!

<ImplicitUsings>disable</ImplicitUsings>

 

Feature 'top-level statements' is not available in C# 7.3. Please use language version 9.0 or greater. Godot Question

回答

I am not entirely sure if that's the snippet of code which produces the top-level statement error. Top-level statement errors usually come from, typically Program.cs, or the code file that contains the Main method.

Top-level statements were introduced with C# 9: MSDN - Top-level statements

In order to enable C# 9.0 in your project, you need to edit your .csproj file and add the following:

<PropertyGroup>
   <LangVersion>9.0</LangVersion>
</PropertyGroup>

Alternatively, you can use the following configuration to target the latest C# version, currently 10.0:

<PropertyGroup>
   <LangVersion>latest</LangVersion>
</PropertyGroup>

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(349)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2018-09-28 通过powershell操作eventlog
2017-09-28 SwitchyOmega
2017-09-28 What's the difference between Unicode and UTF-8?
2015-09-28 让Outlook一直保持开启
点击右上角即可分享
微信分享提示