• <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. 代表上的可选参数无法正常工作

        Optional parameters on delegates doesn#39;t work properly(代表上的可选参数无法正常工作)

            <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);
                  }
                  

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

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

                  相关文档推荐

                  Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)
                  Parameter count mismatch with Invoke?(参数计数与调用不匹配?)
                  How to store delegates in a List(如何将代表存储在列表中)
                  How delegates work (in the background)?(代表如何工作(在后台)?)
                  C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)
                  Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)
                    <tbody id='FfVxB'></tbody>
                    • <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'>

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