<i id='QBNxE'><tr id='QBNxE'><dt id='QBNxE'><q id='QBNxE'><span id='QBNxE'><b id='QBNxE'><form id='QBNxE'><ins id='QBNxE'></ins><ul id='QBNxE'></ul><sub id='QBNxE'></sub></form><legend id='QBNxE'></legend><bdo id='QBNxE'><pre id='QBNxE'><center id='QBNxE'></center></pre></bdo></b><th id='QBNxE'></th></span></q></dt></tr></i><div id='QBNxE'><tfoot id='QBNxE'></tfoot><dl id='QBNxE'><fieldset id='QBNxE'></fieldset></dl></div>

    1. <legend id='QBNxE'><style id='QBNxE'><dir id='QBNxE'><q id='QBNxE'></q></dir></style></legend>
      • <bdo id='QBNxE'></bdo><ul id='QBNxE'></ul>
      <tfoot id='QBNxE'></tfoot>

      <small id='QBNxE'></small><noframes id='QBNxE'>

      在新的 VS Studio 2017 ASP.NET MVC 5.2.3 项目中使用 C# 7 功能时出现编译错误

      Compile errors when using C# 7 features in new VS Studio 2017 ASP.NET MVC 5.2.3 project(在新的 VS Studio 2017 ASP.NET MVC 5.2.3 项目中使用 C# 7 功能时出现编译错误)

      <i id='HOwAp'><tr id='HOwAp'><dt id='HOwAp'><q id='HOwAp'><span id='HOwAp'><b id='HOwAp'><form id='HOwAp'><ins id='HOwAp'></ins><ul id='HOwAp'></ul><sub id='HOwAp'></sub></form><legend id='HOwAp'></legend><bdo id='HOwAp'><pre id='HOwAp'><center id='HOwAp'></center></pre></bdo></b><th id='HOwAp'></th></span></q></dt></tr></i><div id='HOwAp'><tfoot id='HOwAp'></tfoot><dl id='HOwAp'><fieldset id='HOwAp'></fieldset></dl></div>

        <tbody id='HOwAp'></tbody>
          <bdo id='HOwAp'></bdo><ul id='HOwAp'></ul>
          • <small id='HOwAp'></small><noframes id='HOwAp'>

          • <legend id='HOwAp'><style id='HOwAp'><dir id='HOwAp'><q id='HOwAp'></q></dir></style></legend>

                <tfoot id='HOwAp'></tfoot>
                本文介绍了在新的 VS Studio 2017 ASP.NET MVC 5.2.3 项目中使用 C# 7 功能时出现编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我通常将 VS 2017 用于控制台应用程序.但是现在我必须创建一个新的 ASP.NET MVC 项目并发现了一些奇怪的东西.

                I'm using VS 2017 usually for console applications. But now I have to create a new ASP.NET MVC project and found something curious.

                自动生成 getter 和 setter(上下文菜单快速操作和重构 < 封装字段(和使用属性)")引发编译错误.举个简单的例子:

                Auto generation of getter and setter (context menu "Quick actions and refactoring < Ecapsulate field (and use property)") raise a compiling error. To give an easy example:

                public class Person
                {
                    private string firstname;
                
                    public string Firstname { get => firstname; set => firstname = value; }
                }
                

                错误信息:

                1>------ Build started: Project: DummyASPNETMVC, Configuration: Debug Any CPU ------
                1>C:devC#DummyASPNETMVCDummyASPNETMVCModelsPerson.cs(12,39,12,41): error CS1043: { or ; expected
                1>C:devC#DummyASPNETMVCDummyASPNETMVCModelsPerson.cs(12,39,12,41): error CS1513: } expected
                1>C:devC#DummyASPNETMVCDummyASPNETMVCModelsPerson.cs(14,2,14,2): error CS1513: } expected
                ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
                

                取消注释 getter 和 setter 将使事情再次工作.

                Uncomment the getter and setter will make the things working again.

                我想知道,因为这在控制台应用程序中运行良好.这里的区别在哪里?

                I'm wondering because this works fine within a console application. Where's the difference here?

                推荐答案

                感谢 Panagiotis 和 哲也.那是c#的版本.

                Thanks to Panagiotis and Tetsuya. It was the version of c#.

                作为这个问题的参考,你必须做三件事:

                As a reference to this question, you have to do three things:

                1. 通过 Nuget 包管理器卸载Microsoft.CodeDom.Providers.DotNetCompilerPlatform"并重新安装最新版本(当前为 1.0.4)
                2. 在此之后,将 Microsoft.Net.Compilers 更新到最新版本(当前为 2.2.0)
                3. 通过项目properties < build < advanced"将 c# 语言更改为版本 7.

                完成.

                这篇关于在新的 VS Studio 2017 ASP.NET MVC 5.2.3 项目中使用 C# 7 功能时出现编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Force JsonConvert.SerializeXmlNode to serialize node value as an Integer or a Boolean(强制 JsonConvert.SerializeXmlNode 将节点值序列化为整数或布尔值)
                Using JSON to Serialize/Deserialize TimeSpan(使用 JSON 序列化/反序列化 TimeSpan)
                Could not determine JSON object type for type quot;Classquot;(无法确定类型“Class的 JSON 对象类型.)
                How to deserialize a JSONP response (preferably with JsonTextReader and not a string)?(如何反序列化 JSONP 响应(最好使用 JsonTextReader 而不是字符串)?)
                how to de-serialize JSON data in which Timestamp it-self contains fields?(如何反序列化时间戳本身包含字段的JSON数据?)
                JSON.Net custom contract serialization and Collections(JSON.Net 自定义合约序列化和集合)
                  <bdo id='LrnId'></bdo><ul id='LrnId'></ul>

                        <tbody id='LrnId'></tbody>

                      <small id='LrnId'></small><noframes id='LrnId'>

                    • <i id='LrnId'><tr id='LrnId'><dt id='LrnId'><q id='LrnId'><span id='LrnId'><b id='LrnId'><form id='LrnId'><ins id='LrnId'></ins><ul id='LrnId'></ul><sub id='LrnId'></sub></form><legend id='LrnId'></legend><bdo id='LrnId'><pre id='LrnId'><center id='LrnId'></center></pre></bdo></b><th id='LrnId'></th></span></q></dt></tr></i><div id='LrnId'><tfoot id='LrnId'></tfoot><dl id='LrnId'><fieldset id='LrnId'></fieldset></dl></div>
                      <legend id='LrnId'><style id='LrnId'><dir id='LrnId'><q id='LrnId'></q></dir></style></legend>

                          <tfoot id='LrnId'></tfoot>