如何允许我的班级动态添加其他班级的自定义字段和属性 [英] How to allow My class to add custom fields and properties by other class on the fly

查看:65
本文介绍了如何允许我的班级动态添加其他班级的自定义字段和属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过调用class允许在我的班级中添加新字段.

I want to allow new fields to be added in my class by calling class.

推荐答案

^ ]会执行此操作.
This[^] will do it, if anything will.


此处的键是使用System.Reflection.Emit.
请参阅 http://msdn.microsoft.com/en-us/library/3y322t50.aspx [ ^ ].

这是非常困难的主题之一.你真的想要你在问什么吗?您能分享您的最终目标吗?很可能会考虑更简单的方法.

—SA
The key here is using System.Reflection.Emit.
See http://msdn.microsoft.com/en-us/library/3y322t50.aspx[^].

This is one of the very difficult topics. Do you really want what are you asking about? Could you share your ultimate goal of it? Most likely much more simple approach could be considered.

—SA


就像SAKryukov提到的那样,可能有一个更简单的解决方案-显然取决于您的工作.可能是您在寻找附加属性 [
As SAKryukov mentions, there could be a simpler solution - obviously depending on what you are doing. Could it be that you are looking for attached properties[^]

Best regards
Espen Harlinn


这篇关于如何允许我的班级动态添加其他班级的自定义字段和属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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