In the following code we have two classes, the Parent
class uses generics:
abstract class Parent<T>
{
public T Put(T id, char value)
{
return id;
}
}
class Child : Parent<int>
{
public string Get(Guid guid)
{
return "aei";
}
}
But using reflection IsGenericType
on the id
parameter we get False...
I think that should be True, right?
Here is my test code:
public static void Main(string[] args)
{
foreach (var methodInfo in typeof(Child).GetMethods())
{
if (!methodInfo.IsVirtual && methodInfo.GetParameters().Length > 0)
{
Console.WriteLine(methodInfo.Name);
foreach (var param in methodInfo.GetParameters())
{
Console.Write(" " + param.Name + " IsGenericType=");
Console.WriteLine(param.ParameterType.IsGenericType);
}
}
}
}
And output:
Get
guid IsGenericType=False
Put
id IsGenericType=False
value IsGenericType=False
Aucun commentaire:
Enregistrer un commentaire