Can a Delegate have an optional parameter?

前端 未结 2 1017
抹茶落季
抹茶落季 2020-12-06 11:17

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 compil

2条回答
  •  醉梦人生
    2020-12-06 11:37

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

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

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

提交回复
热议问题