StrsdBYVB.NET
October 31st, 2002, 09:22 AM
I'm porting a VB6 app to .NET, but encountering problems iterating through ALL of my embedded dictionaries:
------VB6 code------:
dim dctOne as new Scripting.Dictionary
dim vOne as Variant
dim vTwo as Variant
'dctOne has Key=unique number, Value=Dictionary
For each vOne in dctOne
'Loop through embeded dictionary related to dctOne's
'current key
For each vTwo in dctOne(vOne)
...........
-------.NET code-----:
dim dctOne as _
new System.Collections.Specialized.HybridDictionary
dim deDictEntryOne as System.Collections.DictioaryEntry
dim deDictEntryTwo as System.Collections.DictioaryEntry
'dctOne has Key=unique number, Value=Dictionary
For each deDictEntryOne in dctOne
'Loop through embeded dictionary related to dctOne's
'current key
For each deDictEntryTwo in dctOne(cstr(deDictEntryOne.key))
--------The .NET code on the last line doesn't compile: "Expression is of type 'System.Object', which is not a collection type." SOOOO I'm not sure what is the correct way to do this in .NET.
I don't want to use object data types at all, and NEED to find the correct way to iterate through MANY LEVELS of a dictionary in .NET. It may be that I cannot use DictionaryEntry structure, but I CAN'T FIND DOCUMENTATION ANYWHERE.
I REALLY NEED AND WOULD REALLY APRECIATE ANY KIND OF ADVICE!!!!!!!!!!!!!
THANKS IN ADVANCE
------VB6 code------:
dim dctOne as new Scripting.Dictionary
dim vOne as Variant
dim vTwo as Variant
'dctOne has Key=unique number, Value=Dictionary
For each vOne in dctOne
'Loop through embeded dictionary related to dctOne's
'current key
For each vTwo in dctOne(vOne)
...........
-------.NET code-----:
dim dctOne as _
new System.Collections.Specialized.HybridDictionary
dim deDictEntryOne as System.Collections.DictioaryEntry
dim deDictEntryTwo as System.Collections.DictioaryEntry
'dctOne has Key=unique number, Value=Dictionary
For each deDictEntryOne in dctOne
'Loop through embeded dictionary related to dctOne's
'current key
For each deDictEntryTwo in dctOne(cstr(deDictEntryOne.key))
--------The .NET code on the last line doesn't compile: "Expression is of type 'System.Object', which is not a collection type." SOOOO I'm not sure what is the correct way to do this in .NET.
I don't want to use object data types at all, and NEED to find the correct way to iterate through MANY LEVELS of a dictionary in .NET. It may be that I cannot use DictionaryEntry structure, but I CAN'T FIND DOCUMENTATION ANYWHERE.
I REALLY NEED AND WOULD REALLY APRECIATE ANY KIND OF ADVICE!!!!!!!!!!!!!
THANKS IN ADVANCE