lundi 21 mars 2016

how to use activate.createinstance on 2d string array in reflection

Hi good people of SO,

I am facing a little challenge here and I can't quite figure it out. So I have a 2d array that I've created using the following :

var portTypes = assembly.GetExportedTypes();
string[,] commonIPPort= new string [2,2];
foreach (var v in portTypes )
        {
            if (v.FullName == "iControl.CommonIPPortDefinition")
            {
                commonIPPort= new string[,] { { v.Name, v.FullName }};
            }
        }
dynamic ports= Array.CreateInstance(typeof(object),commonIPPort.Length); 

This is where I get the null error: object item;

for (int i = 0; i < commonIPPort.Length; i++)
        {
            item = Activator.CreateInstance(Type.GetType(commonIPPort[i,i+1]));

        }

so my question is how do you use createinstance on a 2d string?

thank you in advance.





Aucun commentaire:

Enregistrer un commentaire