Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • You cant do that dude. You dont want dynamic objects, you want dynamic variables. Commented Nov 1, 2016 at 19:17
  • Can you edit your question to give a full minimal reproducible example for your problem? It sounds like SelectMany() with ToList() might do the job. Commented Nov 1, 2016 at 19:23
  • 1
    It really looks to me like what you may need is a Dictionary<string, List<MyClass>> or something to that effect. The key would be what you use to access the list for that name and add your class to it. Obviously you would also need to find a way to prevent issues if two people have the same name but hopefully this gave you enough of a hint to point you in the right direction... Commented Nov 1, 2016 at 19:25
  • Are you wanting one instance of MyClass for each row in the table or are you wanting an actual List of MyClass for each row? If you want the List then how should each instance of MyClass be created from one row in the table? It sounds like you might want List<List<MyClass>> in the end. Commented Nov 1, 2016 at 19:33