Click here to Skip to main content
15,888,068 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,

I am generating controls like textbox ,labels dynamically for different subjects which are further dependent on the standard selected now i have to cross check that which controls are generated like if i select standard 9 then controls of subjects would be of Maths, science etc and if i select 11th science then it would be physics , chemistry etc. for that i have taken an bool[] b array in which i specify that b[0] is for Maths and if maths textbox is generated then it is set to true else it is false.

Now what i need is can i have array like this b["Maths"]=true OR b["M"]=true?? i.e. is it possible to traverse or iterate to an array using string or character ??

Please let me know if it is possible ...

Thanks & Regards,
Krunal Panchal
Posted

1 solution

Such indexing functionality is achieved through one of the following generic classes:


These classes are very similar in usage and different mostly in the trade-off between performance and redundancy. The Dictionary class is the most often used. Please see the MSDN help pages referenced above for further detail.

[EDIT]

The traversal of the whole collection can be done through foreach; and the loop variable has the type System.Collections.Generic.KeyValuePair<TKey, TValue>, http://msdn.microsoft.com/en-us/library/5tbh8a42.aspx[^].

—SA
 
Share this answer
 
v4
Comments
Espen Harlinn 12-Mar-12 19:31pm    
5'ed!
Sergey Alexandrovich Kryukov 12-Mar-12 19:40pm    
Thank you, Espen.
--SA
Wonde Tadesse 12-Mar-12 23:38pm    
5+
Sergey Alexandrovich Kryukov 12-Mar-12 23:59pm    
Thank you, Wonde.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900