Hi - the following code outputs:
dictionary True
dictionaryByRef False
I would have expected both parameterTypes to return true for IsGenericType. What gives
cheers, colin
using
System;using
System.Reflection;using
System.Collections.Generic;namespace
AnotherTest {class TestType {
public void EatDictionaries(Dictionary<Int32, String> dictionary, ref Dictionary<Int32, String> dictionaryByRef) {
}
}
class MainClass{public static void Main(String[] args){
Type testType = Type.GetType("AnotherTest.TestType"); MethodInfo method = testType.GetMethod("EatDictionaries"); foreach (ParameterInfo param in method.GetParameters()) {
Console.WriteLine(param.Name + "\t" + param.ParameterType.IsGenericType);
}
Console.Read();}
}
}

why does passing by ref change result of Type.IsGenericType?
Joshd23
When Type.IsByRef is true, you should use Type.GetElementType to get the "base", non-ref type.
emanon
thanks again Mattias,
col