Is there a generic method to iterate and print a values in an unknown collection?
问题 Let's say, I have a Print method like this: private static void Print(IEnumerable items) { // Print logic here } I want to pass a collection class to this Print method, which should print all the fields like a table. For example, my input collection can be "Persons" or "Orders" or "Cars" etc. If I pass the "Cars" collection to the Print method, it should print the list of "Car" details such as: Make, Color, Price, Class etc. I won't know the type of the collection until run-time. I tried and