根据我的法典样本:
public abstract class<T>
{
public List<T> GetSomething(string q)
{
**List<T> list = new List<T>();**
Type type = typeof(T);
PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance);
foreach (PropertyInfo info in props)
{
// at this point I need to return information from a data source query
// and build the members (set values) according to the returning results
// which needs to be added to a list that contains T with each property
// within set to a value. "Some Value" should be an object instance required
// by the Type of the PropertyInfo.
info.SetValue(type, "Some Value", null);
**list.Add(type);**
}
}
**return list;**
}
由于模板类型,无法进入(物体、物体、物体)? 我在此要问的是,我如何确定T中所含财产的价值?
Edit: 问题甚至使人感到困惑。 我对上述程序进行了修改,以反映我的直接需要。
Thanks, Eric