Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
I have two classes Class1 and Program a shown below:
class Class1
 {
     public void xx()
     { 
 
     }
 }
 
 class Program : Class1
 {
     static void Main(string[] args)
     {
 
     }
 }
 
Here is the output from SOS debugger......
!dumpmt -md  00153898
EEClass:      00151474
Module:       00152ea4
Name:         ConsoleApplication24.Program
mdToken:      b1d44c0002000003
File:         E:\c#\ConsoleApplication24\ConsoleApplication24\bin\Debug\ConsoleApplication24.exe
BaseSize:        0xc
ComponentSize:   0x0
Slots in VTable: 6
Number of IFaces in IFaceMap: 0
--------------------------------------
MethodDesc Table
   Entry MethodDesc      JIT Name
530ba790   52e94cd8   PreJIT System.Object.ToString()
530be290   52e94ce0   PreJIT System.Object.Equals(System.Object)
530be1a0   52e94d00   PreJIT System.Object.GetHashCode()
531417b0   52e94d14   PreJIT System.Object.Finalize()
0015c038   0015388c     NONE ConsoleApplication24.Program..ctor()
0015c030   0015387c      JIT ConsoleApplication24.Program.Main(System.String[])
 
But why here i not seen the inherited functions ( ie xx() from Class1 )in "Program class"??????
Because when i create instance of Program class and access method xx() then how it finds the
method????
Posted 10-Nov-12 3:30am
fdiu497
Comments
OriginalGriff at 10-Nov-12 9:43am
   
Don't create a new question to add information - use the Improve Question widget instead.
I have deleted the "spare" question.
Abhishek Pant at 10-Nov-12 9:54am
   
it seems that you didn't created a object to inherit the property of class1

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The compiler already knows it is non-virtual so it directly generates a call to Class1.xx(). Use ildasm.exe to look at the generated IL.
here the address of the method xx() from Class1's method table is burn by clr and emits call to it.Here clr not required the object reference to class1's method table.......clr does it automatically....
  Permalink  
Comments
Nelek at 10-Nov-12 11:06am
   
Is this a solution (it doesn't look like it)? or are you giving further information? You were already told to use the widget "improve question" if you need to edit the text and/or add information to your message
fdiu at 10-Nov-12 13:54pm
   
Why its not looks like solution ?
It is solution... :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 474
1 Maciej Los 375
2 OriginalGriff 263
3 CPallini 214
4 Peter Leow 200
0 OriginalGriff 6,152
1 Sergey Alexandrovich Kryukov 5,312
2 Maciej Los 3,279
3 Peter Leow 3,184
4 DamithSL 2,490


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 10 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100