NET反射创建类属性 [英] .NET Reflection Create Class Properties

查看:163
本文介绍了NET反射创建类属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是相当新的思考,我想知道,如果可能的话,如何创建一个类的实例,然后给类添加属性,设置这些属性,然后再阅读。我没有任何code,因为我不知道如何下手要对此。 C#或VB是好的。

I am fairly new to reflection and I would like to know, if possible, how to create an instance of a class then add properties to the class, set those properties, then read them later. I don't have any code as i don't even know how to start going about this. C# or VB is fine.

感谢您

编辑:(阐述)

我的系统有一个动态的形式创造者。我的一位同事要求表单数据是通过Web服务访问。我的想法是创建一个类(以动态形式)添加属性的类(基于表单字段)设置这些属性(基于值输入这些字段),然后返回类的Web服务。

My system has a dynamic form creator. one of my associates requires that the form data be accessible via web service. My idea was to create a class (based on the dynamic form) add properties to the class (based on the forms fields) set those properties (based on the values input for those fields) then return the class in the web service.

此外,Web服务将可以在类中设置的属性,并最终提交这些更改到数据库。

additionally, the web service will be able to set the properties in the class and eventually commit those changes to the db.

推荐答案

我知道这是被过分受为什么不吻,生成所需的XML通过Web服务来回报,然后解析返回的XML来填充数​​据库简化。

I know this is being overly simplified by why not just KISS and generate the required Xml to return through the Web Service and then parse the returned Xml to populate the database.

我的理由是,为扩展原因,你建议这样做,我可以看到想要一个动态类的价值或理由?

My reasoning is that for the expanded reason you suggest doing this I can see the value or reason for wanting a dynamic class?

这篇关于NET反射创建类属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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