Getting Dictionary<string,string> from List<Control>

Posted by codymanix on Stack Overflow See other posts from Stack Overflow or by codymanix
Published on 2010-04-13T11:09:47Z Indexed on 2010/04/13 11:12 UTC
Read the original article Hit count: 393

Filed under:
|
|
|
|

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));

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET