• <tfoot id='00Jcs'></tfoot>

      <bdo id='00Jcs'></bdo><ul id='00Jcs'></ul>
  • <small id='00Jcs'></small><noframes id='00Jcs'>

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

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

        代表可以有一个可选参数吗?

        Can a Delegate have an optional parameter?(代表可以有一个可选参数吗?)

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

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

                <tbody id='Aa7io'></tbody>
                  <bdo id='Aa7io'></bdo><ul id='Aa7io'></ul>
                • 本文介绍了代表可以有一个可选参数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在我尝试添加 bool NetworkAvailable = true 部分之前,我的以下代码运行良好.现在我在下面的第 4 行得到 Method name expected 编译时异常.

                  I have the below code that was working fine until I tried adding the bool NetworkAvailable = true portion. Now I get a Method name expected compile time exception at Line 4 below.

                  void NetworkStatus_AvailabilityChanged(object sender, NetworkStatusChangedArgs e)
                  {
                     var networkAvailable = e.IsAvailable;
                     SetUpdateHUDConnectedMode d = new SetUpdateHUDConnectedMode(UpdateHUDConnectedMode(networkAvailable));
                     this.Invoke(d);
                  }   
                  
                  delegate void SetUpdateHUDConnectedMode(bool NetworkAvailable = true);
                  private void UpdateHUDConnectedMode(bool NetworkAvailable = true)
                  {
                     ...
                  }
                  

                  诚然,我是 DelegatesOptional Parameters 的新手,因此我将不胜感激.谢谢.

                  I am, admittedly, new to Delegates and Optional Parameters so I would be grateful for any insight. Thanks.

                  推荐答案

                  委托指向方法定义.
                  实例化指向方法的委托时,不能指定任何参数.

                  A delegate points to a method definition.
                  When you instantiate a delegate pointing to a method, you cannot specify any parameters.

                  相反,您需要将参数值传递给 Invoke 方法,如下所示:

                  Instead, you need to pass the parameter values to the Invoke method, like this:

                  SetUpdateHUDConnectedMode d = UpdateHUDConnectedMode;
                  this.Invoke(d, e.IsAvailable);
                  

                  这篇关于代表可以有一个可选参数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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() 和泛型:错误绑定到目标方法)

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

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

                      1. <tfoot id='grkqJ'></tfoot>
                          <tbody id='grkqJ'></tbody>

                            <bdo id='grkqJ'></bdo><ul id='grkqJ'></ul>