I was reading about virtual method tables on wikipedia and I stumbled upon
Whenever a class defines a virtual function (or method), most compilers add a hidden member variable to the class which points to an array of pointers to (virtual) functions called the virtual method table (VMT or Vtable).
However, when I decompile my test code I don't find any member variable in the IL.
I am using latest version of Roslyn to compile (2.6.0).
Here is my test code:
namespace ConsoleApp1
{
using System;
internal class Program
{
private static void Main(string[] args)
{
var a = new Base();
var b = new Derived();
a.Say();
b.Say();
}
}
public class Base
{
public virtual void Say()
{
Console.WriteLine($"{this.GetType()}");
}
}
public class Derived : Base
{
public override void Say()
{
Console.WriteLine($"{this.GetType()}");
}
}
}
I suppose I am misunderstanding something here, could you help me what it is?