0

I am implementing a solution broadly similar to Recursively Get Properties & Child Properties Of An Object, except that I would like a Lookup<string, string> instead of an IEnumerable<string>—the key in the Lookup would be each property.Name, so that a list of the dot notation strings might be easily acccessed by just specifying the property name.

I realise the easiest way for this is to change the IteratePropsInner() method in the answer to package property.Name and the new string $"{baseString}.{property.Name}" into a KeyValuePair, and yield return that.

Now, this will create an IEnumerable<KeyValuePair<string, string>> and there are guaranteed duplicate keys, but with different pairs. I'd like to combine all of them into a Lookup<string, string> so I can quickly return all strings that contain a given property name.

How can I do this?

SRSR333
  • 199
  • 4
  • 12

0 Answers0