Difference between raising event with SomeEvent(arg) and SomeEvent.Invoke(arg)
Is there any difference in using
SomeEvent(arg);
开发者_如何转开发and
SomeEvent.Invoke(arg);
If there is no significant difference, which one is the better practice?
They are exactly the same. The convention is to use the first form though.
No difference, they are equivalent. SomeEvent(arg);
is just syntactic sugar for .Invoke
The first form is C# syntactic sugar for the second. I've not seen anyone use the second form, but I can imagine that some code-generators might in order to "future-proof" the code.
精彩评论