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

      <small id='3eyvD'></small><noframes id='3eyvD'>

      1. <tfoot id='3eyvD'></tfoot>
      2. 代表上的可选参数无法正常工作

        时间:2023-11-10

            <tbody id='CpCij'></tbody>
          <tfoot id='CpCij'></tfoot>

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

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

              <legend id='CpCij'><style id='CpCij'><dir id='CpCij'><q id='CpCij'></q></dir></style></legend>

              • <bdo id='CpCij'></bdo><ul id='CpCij'></ul>

                • 本文介绍了代表上的可选参数无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  为什么这段代码不能编译?

                  Why this piece of code does not compile?

                  delegate int xxx(bool x = true);
                  
                  xxx test = f;
                  
                  int f()
                  {
                     return 4;
                  }
                  

                  推荐答案

                  可选参数用于调用端 - 而不是像单方法接口实现那样有效.例如,这个应该编译:

                  Optional parameters are for use on the calling side - not on what is effectively like a single-method-interface implementation. So for example, this should compile:

                  delegate void SimpleDelegate(bool x = true);
                  
                  static void Main()
                  {
                      SimpleDelegate x = Foo;
                      x(); // Will print "True"
                  }
                  
                  static void Foo(bool y)
                  {
                      Console.WriteLine(y);
                  }
                  

                  这篇关于代表上的可选参数无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:C#中的委托语法问题 下一篇:.NET 委托类型的正确命名约定?

                  相关文章

                  • <bdo id='FfVxB'></bdo><ul id='FfVxB'></ul>
                  <tfoot id='FfVxB'></tfoot>

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

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

                    1. <legend id='FfVxB'><style id='FfVxB'><dir id='FfVxB'><q id='FfVxB'></q></dir></style></legend>