2

I'm learning aspects of the clr in c# and read about this topic in "clr via c# 4th edition".

  1. It is said that each instance of a type has a pointer to a vtable, but in the book they didn't differentiate between static, non-static and virtual methods. According to it all methods are declared in the method table withing the type object. So I think that "vtable" name is misleading, and the virtual methods table is actually only a part of the normal method table in each type object. Is that true?

  2. That would make sense because when calling a virtual method, the object is also referenced and then the clr checks the objects type and calls the method associated with the objects class. Or am I wrong?

  3. Another question: static and non static methods are also in the method table. My understanding is that they are only differentiated by a parameter. Non-static methods are object related, so when calling those methods, a this-pointer is passed in to reveal the object that called it. Static methods do not need this parameter. Am I right?

I know this is quite theoretically but I hope there are people who can help me!

Really nobody?

Community
  • 1
  • 1
Julian Herbold
  • 537
  • 9
  • 20
  • I can't provide a thoroughly accurate answer myself, but this MSDN Magazine article is very informative. http://msdn.microsoft.com/en-us/magazine/cc163791.aspx This might help you. – Jason Evans Apr 10 '14 at 07:39
  • 2
    It is called the "method table" in the CLR. And yes, it contains all methods, not just the virtual ones. So v-table really isn't an appropriate term. Primary reason is that the jitter needs it to know how to compile a call, also important for reflection. Yes, static methods do not have the hidden *this* argument. – Hans Passant Apr 10 '14 at 08:20

0 Answers0