Link to home
Start Free TrialLog in
Avatar of gurteen
gurteen

asked on

is there a way to have something tell me what type the items in the collection are?

Hello-

I have a vendor supplied DLL that I have been using with VB6, and am now switching over to C#.
It seems like what used to be a "Variant" in VB6 now loosely translates to "System.Object" (maybe?)

object rindexTypes;  //1
System.Array myArray; //2
rindexTypes = _pfSet.get_SettingsFactorList(BarraADT.FactorTypes.aegFACTOR_RISKINDEX); //3                  
myArray = (System.Array)rindexTypes; //4
System.Console.WriteLine(myArray.GetUpperBound(0));  //5 returns 12

I have muddled my way through to create this code above, and am concluding that line 3 returns type "System.Object", but that I can convert it to an array, and it has length 12.  I would really like to inspect the actual objects contained, but don't know how to use the foreach, when I don't know
what object type I am working with!  Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gurteen
gurteen

ASKER

Hmm.  This doesn't work.  I'm using .NET 1.1.  There must be something I'm doing wrong.  Thanks for the help though...

c:\Dowd\NET\PortWorkbench\Class1.cs(65): Cannot apply indexing with [] to an expression of type 'System.Array'