Hi Harris,
Actually, The Type object itself holds the information of the underlying
type that
it represents.
So let's assume that your underlying array type is an array of strings.
String[] myStringArray;
typeof(myStringArray).IsArray --- returns true
typeof(myStringArray) ----- is the Type object that represents the
underlying type
typeof(myStringArray).ToString() --- returns System.String[]
So in your example, arrayType itself holds the information on the underlying
array type.
Regards,
Aravind C
"Harris" <mh********@mail.com> wrote in message
news:7d**************************@posting.google.c om...
Does anyone know how to get the underlying type of an Array type?
Here's a bit of code demonstrating what I'm looking for...
public Type getUnderlyingType( Type arrayType )
{
if( !arrayType.IsArray )
throw exception
//get the underlying type and return it
}
In Java you can call Class.getComponentType()? Is there something
similiar in C#?
thanks,
~harris