locked
How to get element type of array? RRS feed

  • Question

  • ICorDebugArrayValue::GetElementType provide a way to get CorElementType enumeration contained information about underlying native type. But it's not enough to get class name if the array contain instances of a class. How to get the name of class of element?
    Monday, May 28, 2007 9:00 AM

Answers

  • Are you using V2.0?  If so, call ICorDebugValue2::GetExactType on your ArrayValue, then use ICorDebugType::GetFirstTypeParameter.  This will give you an ICorDebugType instance for the array element type.

     

    Rick

    Wednesday, May 30, 2007 4:34 PM

All replies

  • You need to get the names from the metadata. You can get a metadata importer from  ICorDebugModule::GetMetadataInterface, and then there are APIs on the importer to convert tokens to string names.

    Tuesday, May 29, 2007 6:24 PM
  • But, ICorDebugArrayValue have not a method to return token for the element type. How to get this token?
    Wednesday, May 30, 2007 7:10 AM
  • Are you using V2.0?  If so, call ICorDebugValue2::GetExactType on your ArrayValue, then use ICorDebugType::GetFirstTypeParameter.  This will give you an ICorDebugType instance for the array element type.

     

    Rick

    Wednesday, May 30, 2007 4:34 PM