How do virtual methods work in C #?

I know that in C ++ there are vpointer and vtable. A virtual function table is a list of pointers to virtual method methods in a class. Each instance of the class has a pointer to a table, which is used when we call the virtual method from the instance.

I want to know how this is implemented in C #. As I understand it, the concept of virtual tables is the same. But what about vpointer, GetType () is used.

I would be grateful for the most detailed details. Thanks.

+7
c #
source share
2 answers

Vtables is one of the possible approaches in C ++, they are not required by the C ++ standard. The .NET approach explicitly uses published standards for the CLI and C #, but implementation details are not specified (and could potentially change).

You can deduce some details from how interfaces, redefined members, and "new" members work.

Why do you want to know this? If you have a specific problem, then the problem will allow others to access it directly.

+7
source share

Take a look at your documentation in C # spec : 10.5.3 Virtual Methods (although this specification is not an implementation).

+1
source share

All Articles