Determine System.Type from an array

  • Thread starter Thread starter Jeremy Chapman
  • Start date Start date
J

Jeremy Chapman

I have System.Type variable containing the value System.String[]

I know that System.String[] means a list of System.String objects, but how
do I programatically get a System.String value from a System.String[] value.

For example, I have a function such as:

public object TestType(System.Type pType)
{
if (pType.Equals(typeof(System.String))
{
}
else
{
}
}

if I call "TestType(typeof(System.String[]));" I want the first if
statement in the TestType method to be execute. How do I do this?
 
Hi Jeremy

I know that System.String[] means a list of System.String objects, but how
do I programatically get a System.String value from a System.String[] value.
public object TestType(System.Type pType)
{
if (pType.Equals(typeof(System.String))
if I call "TestType(typeof(System.String[]));" I want the first if
statement in the TestType method to be execute. How do I do this?


I guess
Type.GetElementType
could help (-> MSDN)
 
Back
Top