虚拟函数在C#内部如何工作? [英] How virtual function works internally in C#?

查看:67
本文介绍了虚拟函数在C#内部如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



请分享您关于虚拟功能的想法.
在使用虚拟函数时,框架或JIT如何在运行时管理代码的执行.它如何与vtable一起工作,以决定必须调用哪个方法?

就像我们有两种使用``override''和``new''关键字使用虚拟方法的方法一样.那么在执行代码时在后台会发生什么.

我在互联网上搜索了很多内容,对我有帮助.

问候,
Prathamesh.

Hi,

Please share your ideas regarding virtual function.
While using virtual function how framework or JIT can manage the execution of code at runtime. How its exactly works with vtable to decide which method has to call?

Like we have two ways to use virtual method using ''override'' and ''new'' keyword. So what happen at background while code execution.

I searched lots on internet for same, help me.

Regards,
Prathamesh.

推荐答案

区别在于new删除了base方法,override意味着您仍然可以调用base.除此之外,您为什么需要确切了解其工作原理?如果您需要知道,请创建基本代码并查看MSIL.

我看不到这与ASP.NET有什么关系.
The difference is that new removes the base method, override means you can still call the base if you want to. Beyond that, why do you need to know exactly how it works ? If you need to know, create basic code and look at the MSIL.

I don''t see what this has to do with ASP.NET.


人们,

经过长时间的搜索,我得到了我的问题的答案.这对我来说有点困难,但真的很高兴知道虚拟功能的工作原理.

我想建议您阅读并尝试深入研究OOP.

这是链接:
Hi People,

After long search I got answer for my question. Its little bit hard for me but its really good to know that HOW VIRTUAL FUNCTION WORKS.

I would like to suggest that to read and try to dive in depth of OOPs.

Here is the link:
Method for implementing virtual function tables in a compiler for an object oriented programming


这篇关于虚拟函数在C#内部如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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