delegate void DelegateTest();
DelegateTest delTest;
Whats the difference between calling delTest.Invoke()
and delTest()
? Both would execute the delegate on the current thread, right?
delegate void DelegateTest();
DelegateTest delTest;
Whats the difference between calling delTest.Invoke()
and delTest()
? Both would execute the delegate on the current thread, right?
Richard's answer is correct, however starting with C# 6.0, there is one situation where using
Invoke()
directly could be advantageous due to the addition of the null conditional operator. Per the MS docs-That's correct. Both have the exact same result.
Given that you have properly initialized
delTest
of course.The
delTest()
form is a compiler helper, underneath it is really a call toInvoke()
.