Object.GetType()来源$ C ​​$ C [英] Object.GetType() source code

查看:154
本文介绍了Object.GetType()来源$ C ​​$ C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是如何的 object.GetType()的.NET中实现的?

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

推荐答案

它在运行时本身实现的,所以没有C#源 - code吧。

It's implemented in the runtime itself, so there is no C# source-code for it.

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

MethodImplOptions.InternalCall 用于其中有一个神奇的执行运行时本身内部的功能。

MethodImplOptions.InternalCall is used for functions which have a "magical" implementation inside the runtime itself.

对于正常的.NET实现你不会找到它,因为在所有的闭源。随着转子或单声道,你很可能会发现自己的C / C ++运行时源 - code。

For the normal .net implementation you won't find it at all since its closed source. With Rotor or Mono you'll most likely find in their c/c++ runtime source-code.

我认为它只是使用了标识指针在每个实例的开始去的类的信息,然后包含字段才能到管理键入例如,可能按需创建它。

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

这篇关于Object.GetType()来源$ C ​​$ C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆