什么是反映在C#中,有什么好处。如何用它来获得benifit它来、如何用、有什么好处、benifit

由网友(罘洅菰憚√)分享简介:我读到一篇文章在MSDN了解反射但我无法了解它绕其benifit,其使用量甚至10%的I was reading an article at msdn about reflection but i was not able to understand it even 10% about its benifit, it...

我读到一篇文章在MSDN了解反射但我无法了解它绕其benifit,其使用量甚至10%的

I was reading an article at msdn about reflection but i was not able to understand it even 10% about its benifit, its usage.

能否请您提供一些简要介绍一下什么是思考,我怎么可以从中受益。

Could you please provide some brief overview what is reflection and how can i take benefit from it.

推荐答案

反射允许你写code,它可以检查有关$ C $各个方面C本身。

Reflection allows you to write code that can inspect various aspects about the code itself.

它可以让你做简单的事情,如:

It enables you to do simple things like:

检查对象的类型,在运行时(简单调用 typeof运算()为例)

检查对象的属性在运行时改变方法的行为(在.NET中的各种序列化方法)

Inspect the Attributes of an object at runtime to change the behavior of a method (the various serialization methods in .NET)

要复杂得多的任务,如:

To much more complicated tasks like:

在加载的程序集在运行时,找到一个特定的类,如果给定的接口匹配确定,并动态地调用某些成员。

较早的是更常见的用法。后来有利于开发人员对谁想要这取决于配置更改交换组件在运行时为他们的应用程序或人的插件架构。

The earlier is much more common usage. The later is helpful to developers working on plug-in architectures for their applications or people who want to swap assemblies at runtime depending on configuration changes.

阅读全文

相关推荐

最新文章