PropertyInfo.GetValue() - how do you index into a generic parameter using reflection in C#?
        Posted  
        
            by 
                flesh
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by flesh
        
        
        
        Published on 2009-06-01T22:59:34Z
        Indexed on 
            2012/07/11
            15:16 UTC
        
        
        Read the original article
        Hit count: 224
        
This (shortened) code..
for (int i = 0; i < count; i++)
{
    object obj = propertyInfo.GetValue(Tcurrent, new object[] { i });
}
.. is throwing a 'TargetParameterCountException : Parameter count mismatch' exception.
The underlying type of 'propertyInfo' is a Collection of some T. 'count' is the number of items in the collection. I need to iterate through the collection and perform an operation on obj.
Advice appreciated.
© Stack Overflow or respective owner