您可以添加indexer属性,一个 伪代码 :
public class MyClass { public object this[string propertyName] { get{// probably faster without reflection:// like: return Properties.Settings.Default.PropertyValues[propertyName] // instead of the followingType myType = typeof(MyClass); PropertyInfo myPropInfo = myType.GetProperty(propertyName);return myPropInfo.GetValue(this, null); } set{Type myType = typeof(MyClass); PropertyInfo myPropInfo = myType.GetProperty(propertyName);myPropInfo.SetValue(this, value, null); } }}

![通过字符串名称设置/获取类属性[重复] 通过字符串名称设置/获取类属性[重复]](http://www.mshxw.com/aiimages/31/470731.png)
