KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
i seem to write this code over and over again and wanted to see if there was a better way of doing it more generically. I start out with a list of Foo objects Foo[] foos = GenerateFoos(); I think want to create a dictionary where the key and value are both properties of Foo for example: Dictionary<string, string> fooDict = new Dictionary<string, string>(): foreach (Foo foo in foos) { fooDict[foo.Name] = foo.StreetAddress; } is there anyway of writing this code generically as it seems like a basic template where there is an array of objects, a key property a value property and a dictionary. Any suggestions? I am using VS 2005 (C#, 2.0)
Tags (comma-separated)
Save Edits
Cancel