【发布时间】:2011-11-17 16:53:52
【问题描述】:
我有以下课程。在 BE(比如说 objBE)的实例中,我想在运行时选择属性名称并为其赋值。例如我们有一个包含所有属性的组合,并且在窗口窗体上有文本框和命令按钮。我想从组合中选择属性名称并在文本框中键入一些值,然后单击按钮我想从 objBE 中查找属性名称并将文本框值分配给选定的属性。无法解决如何完成它。可以帮忙。 提前致谢。 H N
public class MyPropertyBase
{
public int StartOffset { get; set; }
public int EndOffset { get; set; }
}
public class MyProperty<T> : MyPropertyBase
{
public MyProperty(T propertyValue)
{
PropertyValue = propertyValue;
}
public T PropertyValue { get; set; }
public static implicit operator MyProperty<T>(T t)
{
return new MyProperty<T>(t);
}
}
public class BE
{
private List<Admin_Fee> _Admin_Fee = new List<Admin_Fee>();
public MyProperty<int> RFID
{get;set;}
public MyProperty<string> CUSIP
{get;set;}
public MyProperty<string> FUND_CITY
{get;set;}
public MyProperty<int> SomeOtherProperty { get; set; }
//public List<MyPropertyBase> MyDataPoints { get; set; }
public List<Admin_Fee> Admin_Fee
{
get{return _Admin_Fee;}
set{}
}
}
【问题讨论】:
标签: c# .net class generics reflection