lundi 12 septembre 2016

GetConstructors doesn't find the declared constructor

I'm experimenting with System.Type. In the following code, I used GetConstructors on an array type:

using System;
using System.Reflection;

class Animal 
{
    public Animal (string s)
    {
        Console.WriteLine(s);
    }
}

class Test
{
    public static void Main()
    {
        Type AnimalArrayType = typeof(Animal).MakeArrayType();
        Console.WriteLine(AnimalArrayType.GetConstructors()[0]);
    }
}

The output is: Void .ctor(Int32). Why? Shouldn't it be Void .ctor(System.string)?





Aucun commentaire:

Enregistrer un commentaire