In .NET, when you pass an instance / interface of a class as a parameter, you pass a single object or a full vtable

If you pass an interface or an instance of a class as a parameter, we pass many objects or a full vtable, because as soon as you call the method on the instance, it needs to overwrite vtable and call the corresponding right?
How it works?

+3
source share
4 answers

You pass the link (by value). The exact representation of the link is implementation-specific, but in most cases it will be a pointer :)

. http://yoda.arachsys.com/csharp/parameters.html.

( - - , :)

+6

, vtable. , .

+1

, , !:)

btw, there is no such thing as "passing an interface to a parameter". You always pass a reference to an object that can implement any, one or several interfaces.

0
source

Source: https://habr.com/ru/post/1704278/


All Articles