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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top