c# - Access Attributes of object inside a dictionary -
i working on winforms application using c#. have dictionary specific objects, object have attributes id , doctype. how can access attributes of every object in foreach statement. trying following code not working. pls?
foreach (var doc in crs.docdictionary) { console.writeline( doc.id); console.writeline(doc.doctype); }
if foreach
on dictionary sequence of keyvaluepair<tkey,tvalue>
; try:
foreach (var doc in crs.docdictionary.values) { console.writeline(doc.id); console.writeline(doc.doctype); }
or:
foreach (var pair in crs.docdictionary) { console.writeline(pair.key); console.writeline(pair.value.id); console.writeline(pair.value.doctype); }
Comments
Post a Comment