Hi guys,
Following a sample of my code:
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;**
}
info.SetValue(object, object, object[]) is not accessible, due to the template type, correct? My question here would be, how can I set a value on a property, contained within T?
Edit: The question confused even myself. I've amended the procedure above to represent my direct needs.
Thanks, Eric