<small id='2BG0o'></small><noframes id='2BG0o'>

      <bdo id='2BG0o'></bdo><ul id='2BG0o'></ul>

      <tfoot id='2BG0o'></tfoot>
      <legend id='2BG0o'><style id='2BG0o'><dir id='2BG0o'><q id='2BG0o'></q></dir></style></legend>
      <i id='2BG0o'><tr id='2BG0o'><dt id='2BG0o'><q id='2BG0o'><span id='2BG0o'><b id='2BG0o'><form id='2BG0o'><ins id='2BG0o'></ins><ul id='2BG0o'></ul><sub id='2BG0o'></sub></form><legend id='2BG0o'></legend><bdo id='2BG0o'><pre id='2BG0o'><center id='2BG0o'></center></pre></bdo></b><th id='2BG0o'></th></span></q></dt></tr></i><div id='2BG0o'><tfoot id='2BG0o'></tfoot><dl id='2BG0o'><fieldset id='2BG0o'></fieldset></dl></div>
    1. 无法从使用 Visual Studio 2017 和 C# 7.0 的方法返回元组

      时间:2023-05-21

        <tbody id='l1FDc'></tbody>

        <legend id='l1FDc'><style id='l1FDc'><dir id='l1FDc'><q id='l1FDc'></q></dir></style></legend>
      • <tfoot id='l1FDc'></tfoot>
        • <bdo id='l1FDc'></bdo><ul id='l1FDc'></ul>
              • <small id='l1FDc'></small><noframes id='l1FDc'>

                <i id='l1FDc'><tr id='l1FDc'><dt id='l1FDc'><q id='l1FDc'><span id='l1FDc'><b id='l1FDc'><form id='l1FDc'><ins id='l1FDc'></ins><ul id='l1FDc'></ul><sub id='l1FDc'></sub></form><legend id='l1FDc'></legend><bdo id='l1FDc'><pre id='l1FDc'><center id='l1FDc'></center></pre></bdo></b><th id='l1FDc'></th></span></q></dt></tr></i><div id='l1FDc'><tfoot id='l1FDc'></tfoot><dl id='l1FDc'><fieldset id='l1FDc'></fieldset></dl></div>
                本文介绍了无法从使用 Visual Studio 2017 和 C# 7.0 的方法返回元组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我已经安装了一周前发布的 Visual Studio 2017 Community,并开始探索 C# 7 的新功能.

                所以我创建了一个返回两个值的简单方法:

                公开课程序{公共静态无效主要(字符串[]参数){(int sum, int count) a = ReturnTwoValues();}static (int sum, int count) ReturnTwoValues() =>(1, 1);}

                编译器产生错误:

                <块引用>

                错误 CS8137 无法定义使用元组的类或成员因为编译器需要类型'System.Runtime.CompilerServices.TupleElementNamesAttribute' 不能成立.您是否缺少参考资料?

                我尝试在框架中找到具有此名称的引用,但没有成功!

                如果我们需要额外的东西来使用 C# 7.0 的特性,那么我们需要为每个项目都这样做是很奇怪的?!

                解决方案

                我刚刚在

                按照这些步骤,它现在可以工作了.但是,对于我们开始的每个项目都需要这样做,这真的很奇怪!希望当我们正式发布时这个问题得到解决!

                I've installed Visual Studio 2017 Community that was released a week ago, and I started exploring the new features of C# 7.

                So I created a simple method that returns two values:

                public class Program
                {
                    public static void Main(string[] args)
                    {
                        (int sum, int count) a = ReturnTwoValues();
                    }
                
                    static (int sum, int count) ReturnTwoValues() => (1, 1);
                }
                

                Compiler is generating an error:

                Error CS8137 Cannot define a class or member that utilizes tuples because the compiler required type 'System.Runtime.CompilerServices.TupleElementNamesAttribute' cannot be found. Are you missing a reference?

                I tried finding a reference in the framework with this name, but with no luck !

                If we need additional stuff to use C# 7.0 features, then it is very weird that we need to do that for every project ?!

                解决方案

                I Just ran through this page on Roslyn which describes the following steps to get this working:

                1. Start a C# project
                2. Add a reference to the System.ValueTuple package from NuGet (pre-release)

                Following those steps, it is now working. But it is really very weird that we need to do that for every single project that we start! Hope this is fixed when we reach the Official release!

                这篇关于无法从使用 Visual Studio 2017 和 C# 7.0 的方法返回元组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Visual Studio 2017 是否适用于代码合同? 下一篇:将 Visual Studio 2017 与 .Net Core SDK 3.0 一起使用

                相关文章

                1. <tfoot id='eiqF4'></tfoot>

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

                2. <small id='eiqF4'></small><noframes id='eiqF4'>