Why does UdpClient.Receive require a ref parameter?

Why is the UpdClient.Receive a parameter ref

instead of a simple one out

?

According to the MSDN page, the parameter is populated with the address from which the datagram was sent. However, it does not indicate what type of input it is used for, only for output.

+2


a source to share


1 answer


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



This may not always be the case, and they continued to use ref

instead of switching to out

to maintain backward compatibility.

+2


a source







All Articles