Object.GetType () source code

How is it object.GetType()implemented in .NET?

+5
source share
2 answers

It is implemented in the production environment itself, so there is no C # source code for it.

[MethodImpl(MethodImplOptions.InternalCall)]
public extern Type GetType();

MethodImplOptions.InternalCall used for functions that have a "magic" implementation inside the runtime itself.

For a normal .net implementation, you will not find it at all from your private source. With Rotor or Mono, you are most likely to find c / C ++ in the source code.

I assume that it simply uses a marker pointer at the beginning of each instance to retrieve class information, which then contains a field to access the managed instance Type, possibly creating it on demand.

+6
source

, , , " " ++ (, , mono ..).

: , . , , CLI - ECMA335

+1

All Articles