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


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?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
string typeName = ((System.Array)rindexTypes)[0].GetType().ToString();

What does 'typeName' equal?


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gurteenAuthor Commented:
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'
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.