KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm constructing a method to take in an ArrayList(presumably full of objects) and then list all the fields(and their values) for each object in the ArrayList. Currently my code is as follows: public static void ListArrayListMembers(ArrayList list) { foreach (Object obj in list) { Type type = obj.GetType(); string field = type.GetFields().ToString(); Console.WriteLine(field); } } Of course, I understand the immediate issue with this code: if it worked it'd only print one field per object in the ArrayList. I'll fix this later - right now I'm just curious how to get all of the public fields associated with an object.
Tags (comma-separated)
Save Edits
Cancel