c# - enumerate keys in in a System.Collections.Generic.Dictionary<string,string> -


at debug time see keys in initparams collection - can't seem able list them.

initparam

edit:

as jon suggests below, might bug within silverlight debugger. reproduce, create new silverlight application within visual studio 2010 bug silverlight , edit code

{     public partial class mainpage : usercontrol     {         public mainpage()         {             initializecomponent();             var dictionary = new dictionary<string, string> {{"a", "1"}, {"b", "2"}, {"c", "3"}};         }     } } 

assuming want keys, use keys property:

foreach (string key in dict.keys) {     ... } 

if want keys in easy-to-read manner in immediate window, use:

string.join(";", dict.keys) 

or pre-.net 4:

string.join(";", dict.keys.toarray()) 

... or if you're using .net 2, this:

string.join(";", new list<string>(dict.keys).toarray()) 

if want values @ same time, can iterate on keyvaluepair entries per yaakov's answer.

edit: have expected visual studio show nice representation of dictionary default, honest. example, see in vs2008:

dictionary in visual studio

... , i've tried in vs2010 , seen same result. under debugging general options, have got "show raw structure of objects in variable windows" ticked? if so, untick it.


Comments

Popular posts from this blog

c# - BasicHttpBinding equivalent CustomBinding using WCF Client and PHP WebService -

sql server - python to mssql encoding problem -

java - SNMP4J General Variable Binding Error -