开发者

Why does UdpClient.Receive require a ref parameter?

开发者 https://www.devze.com 2022-12-30 23:27 出处:网络
Why is the parameter on UpdClient.Receive a ref parameter, instead of simply out? According to the MSDN page, the parameter is filled with the address 开发者_如何学Cthat the datagram was sent from. H

Why is the parameter on UpdClient.Receive a ref parameter, instead of simply out?

According to the MSDN page, the parameter is filled with the address 开发者_如何学Cthat the datagram was sent from. However it doesn't specify what kind of input it is used for, only output.


This looks like one of those (remarkably rare) BCL inconsistencies/discrepancies. This parameter is not used as input in the method at all (as shown by Reflector).

Perhaps this was not always the case and they kept using ref instead of switching to out to preserve backwards compatibility.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号