4 ms·
Just for completeness, I believe C# fits with C++, which is something that can occasionally catch a Java developer.
by jdmichal 10y ago
Just for completeness, I believe C# fits with C++, which is something that can occasionally catch a Java developer.
- pjmlp 10y agoC# is actually a mix. It uses static dispatch by default, virtual dispatch like C++ and Object Pascal, dynamic dispatch like Objective-C.
- noblethrasher 10y agoInterestingly, while the C# language uses static dispatch by default, it is at least the case that Microsoft's compiler always emits the `callvirt` instruction[1]. This is because the language spec requires that a method call to a null instance of a reference type must throw a NullReferenceException, and callvirt is apparently the cheapest way to do that on the CLR. [1] https://blogs.msdn.microsoft.com/ericgu/2008/07/02/why-does-c-always-use-callvirt/ https://blogs.msdn.microsoft.com/ericgu/2008/07/02/why-does-... [2] §6.1 of the C# language spec.
- KingOfBrian 10y agoI've only used C# very topically. Do you have any documentation that describes how it behaves?
- pjmlp 10y agoNot sure, I guess this video could be interesting: https://www.microsoft.com/resources/msdn/en-us/msdntv/20051103CLRJP.html https://www.microsoft.com/resources/msdn/en-us/msdntv/200511... For dynamic invocations, Objective-C style, you can see here: https://msdn.microsoft.com/en-us/library/dd264741.aspx https://msdn.microsoft.com/en-us/library/dd264741.aspx https://msdn.microsoft.com/en-us/library/ee461504.aspx#Anchor_1 https://msdn.microsoft.com/en-us/library/ee461504.aspx#Ancho...