Are event arguments passed by reference or value in C#?

前端 未结 4 1854
栀梦
栀梦 2021-02-19 08:53

A rather simple question (I think), but I don\'t seem to see an answer already. I know that some values are passed via value (like int and long), and others are passed by refer

4条回答
  •  佛祖请我去吃肉
    2021-02-19 09:20

    The event arguments are passed according to the type of the arguments and the signature of the event handler's delegate (in, out or ref) - if it is a class, then a copy of the reference is passed, if it is a struct, then the copy of the value is passed (assuming signature does not specify out or ref).

    The event arguments are usually a class (usually inherits from EventArgs) and are often used to return values such as eventArgs.DoCancel to the caller.

提交回复
热议问题