什么是反映在C#中,有什么好处。如何用它来获得benifit [英] what is reflection in C#, what are the benefit. How to use it to get benifit

查看:199
本文介绍了什么是反映在C#中,有什么好处。如何用它来获得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, 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:

  1. 检查对象的类型,在运行时(简单调用 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:

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

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

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.

这篇关于什么是反映在C#中,有什么好处。如何用它来获得benifit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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