Getting Dictionary<string,string> from List<Control>
- by codymanix
I want a dictionary containing the names and text of all controls. Is it possible with predefined framework methods/LINQ/colection initializers or do I have to make a loop and add all entries by myself?
This gives me an error message:
List<Control> controls;
// .. initialize list ..
controls.ToDictionary((Control child,string k)=>new KeyValuePair<string,string>(child.Name, child.Text));