2
Reply

Casting object to get at contents?

Matt Funke

Matt Funke

Dec 17 2009 9:18 AM
4.3k

Please forgive me if this is a simple question -- I'm pretty new to C#.

Here's a quick code snippet that tries to take advantage of the ClearQuest API:

ClearQuestOleServer.SessionClass cqSession = new ClearQuestOleServer.SessionClass();
cqSession.UserLogon(login, password, dbName, (int)ClearQuestConstants.SessionType.AD_PRIVATE_SESSION, "");
object cqEntities = cqSession.GetEntityDefNames();

Now, when I run through this in the debugger and watch cqEntities, I can see that it's an array of strings (the "Type" field even claims that it's an "object {object[]}" type, with each item within it an "object {string}" type), but C# won't let me cast cqEntities as a string[], nor will it let me use cqEntities in a foreach (since it's not enumerable). What can I do to get at the stringy contents?

Thanks for any help you can offer!


Answers (2)