当我声明一个类的内部时,为什么IL表明它作为私人? [英] When I declare a class as internal, why does the IL show it as private?
本文介绍了当我声明一个类的内部时,为什么IL表明它作为私人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我声明一个类内部,为何IL表明它作为私人?
内部类的事
的.class私人汽车ANSI beforefieldinit Thing.Thing
扩展[mscorlib程序] System.Object的
解决方案
从IL的角度来看,私人
手段的私有的组装的,即内部
在C#。
在C#中,这是不可能的标记类型为私人
如果他们不能的nested 。 IL等效访问这种类型是嵌套的私人
。
因此,我们有:
- 在C#中的
内部
- > IL的私人
(向大会) - 在C#中的
私人
- > IL的嵌套的私人
(以封闭类型)
If I declare a class as internal, why does the IL show it as private?
internal class Thing
.class private auto ansi beforefieldinit Thing.Thing
extends [mscorlib]System.Object
解决方案
From IL's point of view, private
means private to the assembly, i.e. internal
in C#.
In C#, it is not possible to mark types as private
if they are not nested. IL's equivalent accessibility for such types is nested private
.
So we have:
- C#'s
internal
-> IL'sprivate
(to the assembly) - C#'s
private
-> IL'snested private
(to the enclosing type)
这篇关于当我声明一个类的内部时,为什么IL表明它作为私人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文