I have a method where I can only retrieve the object type at runtime. I tried to cast it to a list of known object, but I failed.
private string outputParamForListOrDict(IMethodReturn returnValue)
{
StringBuilder sb = new StringBuilder();
String outputString = string.Empty;
switch (returnValue.ReturnValue.GetType().GetGenericArguments()[0].Name)
{
case nameof(ViewDocumentReport):
List<ViewDocumentReport> _viewDocumentParam = (List<ViewDocumentReport>)returnValue.ReturnValue;
//process the data here........
return sb.ToString();
//Other object cases
}
}
I got an exception below:
"Unable to cast object of type >'<TakeIterator>d__25`1[ezAcquire.RMS.Model.ViewModels.ViewDocumentReport]' to type 'System.Collections.Generic.List`1[ezAcquire.RMS.Model.ViewModels.ViewDocumentReport]'."}
I put a breakpoint in debug mode.
My returnValue.ReturnValue is of
and if I expand I can see there a list of List.
can someone explain to me what is the d_25 meant, and advice me on how should I cast it correctly during runtime?
Thanks