Why can't an out parameter have a default value?

后端 未结 5 809
心在旅途
心在旅途 2020-12-18 21:24

Currently when trying to do something in a method that takes an out parameter, I need to assign the value of the out parameter in the method body, e.g.

publi         


        
5条回答
  •  执笔经年
    2020-12-18 22:04

    Default parameter values are the default value for parameters passed in to the method. You have to specify a variable to pass for an out parameter so that you can get the returned value.

    Your first example, in a way, has a default, set at the beginning of the method.

提交回复
热议问题