I wrote a method that accepts a generic parameter and then it prints its properties. I use it to test my web service. It\'s working but I want to add some features that I do
The elements inside a list can be retrieved through the indexer property Item
. This property accepts an index argument (there is an overload of PropertyInfo.GetValue
that accept an object
array, just like MethodInfo.Invoke
) and returns the object at that position.
int index = /* the index you want to get here */;
PropertyInfo indexer = Object.GetProperty("Item");
object item = indexer.GetValue(Object, new object[] { index });