C # / vb.net type of inconsistency when searching for a constructor by reflection (Integer () vs System.Int32 [])

I pass the type name and some parameters from C # code to a navigation structure written in VB. The navigation structure looks for a type constructor that matches the parameters passed using Type.GetConstructor (Types ()). The constructor I'm looking for expects an array of integers - Integer () in vb. But it gets an array of System.Int32. I went so far as to try this:

           System.Int32[] int32Array = IdList.ToArray();
            int[] intArray = new int[int32Array.Length];
            for (int i = 0; i < int32Array.Length; i++ )
            {
                intArray[i] = (int)int32Array[i];
            }

And the VB code still sees System.Int32 on the other end, which means that it does not find the constructor.

Any ideas?

+3
source share
2 answers

# int System.Int32, VB Integer . , .

, GetConstructor.

+2

, , , .

Type.GetConstructor(Type[]) , , .

.

(System.Int32) , , .

# , GetConstructor, :

Type[] types = new Type[] { typeof(Int32[]) };

, :

Type[] types = (from v in arr select v.GetType()).ToArray();

, GetConstructor , .

, ?

, , .

+1

Source: https://habr.com/ru/post/1730608/


All Articles