Reflection - method parameter marked as "out" doesn't have a BaseType

T

timnels

I've got some code that is trolling through and assembly looking for
methods that have parameters whose BaseType is DataSet (they are
strongly-typed DataSets). .ParameterType.BaseType is always DataSet
for parameters that are passed like:

MyMethod(MyStronglyTypedDataSet myDataSet);

.... but the BaseType is null for :

MyMethod(out MyStronglyTypedDataSet myDataSet);

Does anyone know why this is happening. How can I tell what the
BaseType this parameter is? T
 
J

Jon Skeet [C# MVP]

I've got some code that is trolling through and assembly looking for
methods that have parameters whose BaseType is DataSet (they are
strongly-typed DataSets). .ParameterType.BaseType is always DataSet
for parameters that are passed like:

MyMethod(MyStronglyTypedDataSet myDataSet);

... but the BaseType is null for :

MyMethod(out MyStronglyTypedDataSet myDataSet);

Does anyone know why this is happening. How can I tell what the
BaseType this parameter is? T

Use Type.HasElementType/Type.GetElementType() to get the "non-out"
type, and then you can find the base type from that.

Jon
 
T

timnels

Use Type.HasElementType/Type.GetElementType() to get the "non-out"
type, and then you can find the base type from that.

Jon

Thanks Jon! That did the trick!
 

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

Top