在.Net中加载类 [英] Loading of a Class in .Net

查看:98
本文介绍了在.Net中加载类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请说明在加载类时发生的过程

Explain me when a class is loaded waht the process take place

推荐答案

请在此处查看本文:http://msdn.microsoft.com/en-us/magazine/cc163791.aspx [
Please look into this article here: http://msdn.microsoft.com/en-us/magazine/cc163791.aspx[^].

Best regards,

—MRB


一个类根本没有加载".加载后,它静态存在于装配体中.所加载程序集的代码不涉及任何部分.该类在程序集中静态存在,其方式与代码的任何部分相同.

同时,如果类具有需要初始化的静态成员,则在加载程序集(或使用程序集的进程)时会预先准备初始化代码.顺便说一下,这创建了一个有趣的代码案例,该案例在启动应用程序入口点(Main)之前运行.

因此,术语加载"不适用于类.主活动在创建类的实例时发生.这称为构造(是初始化的一种情况),不会加载,这不是您所要的.

—SA
A class is not "loaded" at all. It statically exists in an assembly after it is loaded. No part of code of the loaded assembly is involved in it. The class statically exists in an assembly in the same way as any part of the code.

At the same time, if a class has static members which need initialization, the initialization code is pre-elaborated when an assembly (or rather a process using assembly) is loaded. By the way, this creates an interesting case of the code which runs before application entry point (Main) is started.

So, the term loaded is not applicable to classes. Main activity takes place when an instance of the class is created. This is called construction (a case of initialization), not loading, and this is not what you have asked about.

—SA


这篇关于在.Net中加载类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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