如何在C#4中创建一个动态类? [英] How do create a Dynamic class in C# 4?
本文介绍了如何在C#4中创建一个动态类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在ruby中,这是method_missing的。在Perl中,这是AUTOLOAD。
我似乎找不到C#中System.Dynamic的方式。
解决方案
尝试使用 System.Dynamic.DynamicObject 作为一个简单的起始点和基类。您可以在 http://winterdom.com/2009/05/dynamicobject上找到一个例子-in-c-40 。
I want to create an object in C# and have it do interesting things based on the name of the non-existent method that gets.
In ruby, this is method_missing. In Perl, this is AUTOLOAD.
I can't seem to find the way into System.Dynamic in C#.
解决方案
Try using System.Dynamic.DynamicObject as a simple starting point and base class. You can find an example at http://winterdom.com/2009/05/dynamicobject-in-c-40.
这篇关于如何在C#4中创建一个动态类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文