I am trying to use generic list as cast of the object. i have seen related questions and tried but didn't get, what i expected.
In the below code i am setting the value to the main response.
Here is code:
Type type = Type.GetType("className, AssemblyName"); <br/>
var z = typeof(List<>).MakeGenericType(type);
foreach (var key in abc.Keys)
{
var value = abc[key];
foreach (var property in ((List<z>)output.Response)[0].GetType().GetProperties().Where(p => p.CanRead && p.GetMethod.IsPublic).)
{
if(property.Name == ((List<Document>)value)[0].GetType().Name)
{
PropertyInfo propertyInfo = ((List<Policy>)output.Response)[0].GetType().GetProperty(property.Name);
propertyInfo.SetValue(((List<Policy>)output.Response)[0], ((List<Document>)value));
}
}
}
while accessing z
in list. i am unable to do that. I have stuck from past few hour.Please help me out.
Thanks in Advance!