C# 一个关于 .NET 反射的好的完整教程?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9428779/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 07:23:20  来源:igfitidea点击:

A good and complete tutorial about reflection in .NET?

c#.netvb.netreflection

提问by GianT971

the question almost says it all. I think all of you know about the visual studio designer, and how it can show any property of an object, regardless of its type, provided that the property is allowed to be shown in the designer.

这个问题几乎说明了一切。我想你们都知道Visual Studio 设计器,以及它如何显示对象的任何属性,无论其类型如何,前提是该属性允许在设计器中显示。

I am working on a function that could achieve the same thing, but for this, I need a complete tutorialabout reflection, so that this function can treat every type of property.

我正在开发一个可以实现相同功能的函数,但为此,我需要一个关于反射完整教程,以便该函数可以处理每种类型的属性。

Any suggestions?

有什么建议?

回答by user1234883

Here some info:

这里有一些信息:

However, I'd recommend a bit different although harder approach. If you really want to completely understand the topic, that's what you need.

但是,我建议采用更难的方法。如果你真的想完全理解这个主题,那就是你所需要的。

Read Standard ECMA-335Partition II: Metadata Definition and Semantics which explains how .NET uses its metadata

阅读标准 ECMA-335第二部分:元数据定义和语义,其中解释了 .NET 如何使用其元数据

Then read and understand some code that reads this metadata. Mono.Cecil would be a good candidate.

然后阅读并理解一些读取此元数据的代码。Mono.Cecil 将是一个很好的候选人。

That will completely cover the Reflection topic

这将完全涵盖反射主题