Cannot convert from 'System.Array' to 'int[*]' The Next CEO of Stack OverflowWhat does int[*] mean in C# under Visual studio 2017Cast int to enum in C#Create ArrayList from arrayPHP: Delete an element from an arrayHow do I parse a string to a float or int in Python?Get int value from enum in C#How to convert UTF-8 byte[] to string?How do I generate a random int number?How do I convert a String to an int in Java?Easiest way to convert int to string in C++How do I remove a particular element from an array in JavaScript?

Rotate a column

What flight has the highest ratio of time difference to flight time?

How did the Bene Gesserit know how to make a Kwisatz Haderach?

How to invert MapIndexed on a ragged structure? How to construct a tree from rules?

Indicator light circuit

Elegant way to replace substring in a regex with optional groups in Python?

Why do airplanes bank sharply to the right after air-to-air refueling?

Novel about a guy who is possessed by the divine essence and the world ends?

Won the lottery - how do I keep the money?

Why do remote companies require working in the US?

Is it ever safe to open a suspicious html file (e.g. email attachment)?

How does the mv command work with external drives?

How does the Z80 determine which peripheral sent an interrupt?

Interfacing a button to MCU (and PC) with 50m long cable

Multiple labels for a single equation

Is "for causing autism in X" grammatical?

Return the Closest Prime Number

Contours of a clandestine nature

What benefits would be gained by using human laborers instead of drones in deep sea mining?

Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?

What's the best way to handle refactoring a big file?

Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?

Can I equip Skullclamp on a creature I am sacrificing?

Received an invoice from my ex-employer billing me for training; how to handle?



Cannot convert from 'System.Array' to 'int[*]'



The Next CEO of Stack OverflowWhat does int[*] mean in C# under Visual studio 2017Cast int to enum in C#Create ArrayList from arrayPHP: Delete an element from an arrayHow do I parse a string to a float or int in Python?Get int value from enum in C#How to convert UTF-8 byte[] to string?How do I generate a random int number?How do I convert a String to an int in Java?Easiest way to convert int to string in C++How do I remove a particular element from an array in JavaScript?










0















In the application I was asked to develop, I must interface with a dll over which I have no control.



From the dll, I'm calling:



NAMESPACE.myFunction(string Name, int[*] Coordinates)


What is this int[*] type? Answer was easy found here: it is a non-0 based array. This question briefly mentions some LabView compiled dll, which is very similar to my present case.



I was able to determine via researching that only an Array can be used to to have a int32[*] type. An easy way to prove it is to run this code:



Array AAA = Array.CreateInstance(typeof(int), 4, 0);
Array AAA2 = Array.CreateInstance(typeof(int), 4, 1);
Array BBB = Array.CreateInstance(typeof(int), 4);
Array CCC = Array.CreateInstance(typeof(int), new int[] 4 , new int[] 0 );
Array DDD = Array.CreateInstance(typeof(int), new int[] 4 );

int[] arr1 = (int[])Array.CreateInstance(typeof(int), 4);
int[] arr2 = (int[])Array.CreateInstance(typeof(int), new int[] 4 , new int[] 0 );
Array arr3 = Array.CreateInstance(typeof(int), new int[] 4 , new int[] 1 );

Console.WriteLine("AAA.type: " + AAA.GetType()); \ System.Int32[,]
Console.WriteLine("AAA2.type: " + AAA2.GetType()); \ System.Int32[,]
Console.WriteLine("BBB.type: " + BBB.GetType()); \ System.Int32[]
Console.WriteLine("CCC.type: " + CCC.GetType()); \ System.Int32[]
Console.WriteLine("DDD.type: " + DDD.GetType()); \ System.Int32[]
Console.WriteLine("---");
Console.WriteLine("arr1.type: " + arr1.GetType()); \ System.Int32[]
Console.WriteLine("arr2.type: " + arr2.GetType()); \ System.Int32[]
Console.WriteLine("arr3.type: " + arr3.GetType()); \ System.Int32[*]


The question I can't find an answer to is: how do I pass an Array type to my method call, without the conversion type error? Error is thrown by this call:



NAMESPACE.myFunction("", arr3)
^
Cannot convert from 'System.Array' to 'int[*]'









share|improve this question

















  • 1





    exposing an API with a non-vector typed array is ... just asking for pain. That isn't a thing that you can cleanly express in C#; what is NAMESPACE.myFunction? is this a third party thing? can you change the signature, or request it be changed?

    – Marc Gravell
    Mar 7 at 15:47







  • 1





    note: if the API is instance based, not static based, you might be able to cheat by using dynamic...

    – Marc Gravell
    Mar 7 at 15:48






  • 1





    You can't keep the C# compiler happy. Use ildasm.exe to decompile the assembly, edit the IL and change the argument to Array, put it back together with ilasm.exe. If this is likely to change soon then you do want to contact the author to get this right.

    – Hans Passant
    Mar 7 at 15:54











  • @MarcGravell, it is a third party thing, called by National Instruments TestStand passing an Array of Numbers (Int32). Unfortunately, we'd like to move away from TestStand, so I'm trying to call it from a c# app, instead. Under all points of view, I don't see it changing soon, I can't get hold of the developer/maintainer, so it is sealed third party for me.

    – Daemon Painter
    Mar 7 at 16:04












  • @MarcGravell, the dynamic solution is reporting this, instead: Unable to cast object of type 'System.Int32[*]' to type 'System.Int32[]'.

    – Daemon Painter
    Mar 7 at 16:20
















0















In the application I was asked to develop, I must interface with a dll over which I have no control.



From the dll, I'm calling:



NAMESPACE.myFunction(string Name, int[*] Coordinates)


What is this int[*] type? Answer was easy found here: it is a non-0 based array. This question briefly mentions some LabView compiled dll, which is very similar to my present case.



I was able to determine via researching that only an Array can be used to to have a int32[*] type. An easy way to prove it is to run this code:



Array AAA = Array.CreateInstance(typeof(int), 4, 0);
Array AAA2 = Array.CreateInstance(typeof(int), 4, 1);
Array BBB = Array.CreateInstance(typeof(int), 4);
Array CCC = Array.CreateInstance(typeof(int), new int[] 4 , new int[] 0 );
Array DDD = Array.CreateInstance(typeof(int), new int[] 4 );

int[] arr1 = (int[])Array.CreateInstance(typeof(int), 4);
int[] arr2 = (int[])Array.CreateInstance(typeof(int), new int[] 4 , new int[] 0 );
Array arr3 = Array.CreateInstance(typeof(int), new int[] 4 , new int[] 1 );

Console.WriteLine("AAA.type: " + AAA.GetType()); \ System.Int32[,]
Console.WriteLine("AAA2.type: " + AAA2.GetType()); \ System.Int32[,]
Console.WriteLine("BBB.type: " + BBB.GetType()); \ System.Int32[]
Console.WriteLine("CCC.type: " + CCC.GetType()); \ System.Int32[]
Console.WriteLine("DDD.type: " + DDD.GetType()); \ System.Int32[]
Console.WriteLine("---");
Console.WriteLine("arr1.type: " + arr1.GetType()); \ System.Int32[]
Console.WriteLine("arr2.type: " + arr2.GetType()); \ System.Int32[]
Console.WriteLine("arr3.type: " + arr3.GetType()); \ System.Int32[*]


The question I can't find an answer to is: how do I pass an Array type to my method call, without the conversion type error? Error is thrown by this call:



NAMESPACE.myFunction("", arr3)
^
Cannot convert from 'System.Array' to 'int[*]'









share|improve this question

















  • 1





    exposing an API with a non-vector typed array is ... just asking for pain. That isn't a thing that you can cleanly express in C#; what is NAMESPACE.myFunction? is this a third party thing? can you change the signature, or request it be changed?

    – Marc Gravell
    Mar 7 at 15:47







  • 1





    note: if the API is instance based, not static based, you might be able to cheat by using dynamic...

    – Marc Gravell
    Mar 7 at 15:48






  • 1





    You can't keep the C# compiler happy. Use ildasm.exe to decompile the assembly, edit the IL and change the argument to Array, put it back together with ilasm.exe. If this is likely to change soon then you do want to contact the author to get this right.

    – Hans Passant
    Mar 7 at 15:54











  • @MarcGravell, it is a third party thing, called by National Instruments TestStand passing an Array of Numbers (Int32). Unfortunately, we'd like to move away from TestStand, so I'm trying to call it from a c# app, instead. Under all points of view, I don't see it changing soon, I can't get hold of the developer/maintainer, so it is sealed third party for me.

    – Daemon Painter
    Mar 7 at 16:04












  • @MarcGravell, the dynamic solution is reporting this, instead: Unable to cast object of type 'System.Int32[*]' to type 'System.Int32[]'.

    – Daemon Painter
    Mar 7 at 16:20














0












0








0








In the application I was asked to develop, I must interface with a dll over which I have no control.



From the dll, I'm calling:



NAMESPACE.myFunction(string Name, int[*] Coordinates)


What is this int[*] type? Answer was easy found here: it is a non-0 based array. This question briefly mentions some LabView compiled dll, which is very similar to my present case.



I was able to determine via researching that only an Array can be used to to have a int32[*] type. An easy way to prove it is to run this code:



Array AAA = Array.CreateInstance(typeof(int), 4, 0);
Array AAA2 = Array.CreateInstance(typeof(int), 4, 1);
Array BBB = Array.CreateInstance(typeof(int), 4);
Array CCC = Array.CreateInstance(typeof(int), new int[] 4 , new int[] 0 );
Array DDD = Array.CreateInstance(typeof(int), new int[] 4 );

int[] arr1 = (int[])Array.CreateInstance(typeof(int), 4);
int[] arr2 = (int[])Array.CreateInstance(typeof(int), new int[] 4 , new int[] 0 );
Array arr3 = Array.CreateInstance(typeof(int), new int[] 4 , new int[] 1 );

Console.WriteLine("AAA.type: " + AAA.GetType()); \ System.Int32[,]
Console.WriteLine("AAA2.type: " + AAA2.GetType()); \ System.Int32[,]
Console.WriteLine("BBB.type: " + BBB.GetType()); \ System.Int32[]
Console.WriteLine("CCC.type: " + CCC.GetType()); \ System.Int32[]
Console.WriteLine("DDD.type: " + DDD.GetType()); \ System.Int32[]
Console.WriteLine("---");
Console.WriteLine("arr1.type: " + arr1.GetType()); \ System.Int32[]
Console.WriteLine("arr2.type: " + arr2.GetType()); \ System.Int32[]
Console.WriteLine("arr3.type: " + arr3.GetType()); \ System.Int32[*]


The question I can't find an answer to is: how do I pass an Array type to my method call, without the conversion type error? Error is thrown by this call:



NAMESPACE.myFunction("", arr3)
^
Cannot convert from 'System.Array' to 'int[*]'









share|improve this question














In the application I was asked to develop, I must interface with a dll over which I have no control.



From the dll, I'm calling:



NAMESPACE.myFunction(string Name, int[*] Coordinates)


What is this int[*] type? Answer was easy found here: it is a non-0 based array. This question briefly mentions some LabView compiled dll, which is very similar to my present case.



I was able to determine via researching that only an Array can be used to to have a int32[*] type. An easy way to prove it is to run this code:



Array AAA = Array.CreateInstance(typeof(int), 4, 0);
Array AAA2 = Array.CreateInstance(typeof(int), 4, 1);
Array BBB = Array.CreateInstance(typeof(int), 4);
Array CCC = Array.CreateInstance(typeof(int), new int[] 4 , new int[] 0 );
Array DDD = Array.CreateInstance(typeof(int), new int[] 4 );

int[] arr1 = (int[])Array.CreateInstance(typeof(int), 4);
int[] arr2 = (int[])Array.CreateInstance(typeof(int), new int[] 4 , new int[] 0 );
Array arr3 = Array.CreateInstance(typeof(int), new int[] 4 , new int[] 1 );

Console.WriteLine("AAA.type: " + AAA.GetType()); \ System.Int32[,]
Console.WriteLine("AAA2.type: " + AAA2.GetType()); \ System.Int32[,]
Console.WriteLine("BBB.type: " + BBB.GetType()); \ System.Int32[]
Console.WriteLine("CCC.type: " + CCC.GetType()); \ System.Int32[]
Console.WriteLine("DDD.type: " + DDD.GetType()); \ System.Int32[]
Console.WriteLine("---");
Console.WriteLine("arr1.type: " + arr1.GetType()); \ System.Int32[]
Console.WriteLine("arr2.type: " + arr2.GetType()); \ System.Int32[]
Console.WriteLine("arr3.type: " + arr3.GetType()); \ System.Int32[*]


The question I can't find an answer to is: how do I pass an Array type to my method call, without the conversion type error? Error is thrown by this call:



NAMESPACE.myFunction("", arr3)
^
Cannot convert from 'System.Array' to 'int[*]'






c# arrays type-conversion






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 7 at 15:35









Daemon PainterDaemon Painter

294112




294112







  • 1





    exposing an API with a non-vector typed array is ... just asking for pain. That isn't a thing that you can cleanly express in C#; what is NAMESPACE.myFunction? is this a third party thing? can you change the signature, or request it be changed?

    – Marc Gravell
    Mar 7 at 15:47







  • 1





    note: if the API is instance based, not static based, you might be able to cheat by using dynamic...

    – Marc Gravell
    Mar 7 at 15:48






  • 1





    You can't keep the C# compiler happy. Use ildasm.exe to decompile the assembly, edit the IL and change the argument to Array, put it back together with ilasm.exe. If this is likely to change soon then you do want to contact the author to get this right.

    – Hans Passant
    Mar 7 at 15:54











  • @MarcGravell, it is a third party thing, called by National Instruments TestStand passing an Array of Numbers (Int32). Unfortunately, we'd like to move away from TestStand, so I'm trying to call it from a c# app, instead. Under all points of view, I don't see it changing soon, I can't get hold of the developer/maintainer, so it is sealed third party for me.

    – Daemon Painter
    Mar 7 at 16:04












  • @MarcGravell, the dynamic solution is reporting this, instead: Unable to cast object of type 'System.Int32[*]' to type 'System.Int32[]'.

    – Daemon Painter
    Mar 7 at 16:20













  • 1





    exposing an API with a non-vector typed array is ... just asking for pain. That isn't a thing that you can cleanly express in C#; what is NAMESPACE.myFunction? is this a third party thing? can you change the signature, or request it be changed?

    – Marc Gravell
    Mar 7 at 15:47







  • 1





    note: if the API is instance based, not static based, you might be able to cheat by using dynamic...

    – Marc Gravell
    Mar 7 at 15:48






  • 1





    You can't keep the C# compiler happy. Use ildasm.exe to decompile the assembly, edit the IL and change the argument to Array, put it back together with ilasm.exe. If this is likely to change soon then you do want to contact the author to get this right.

    – Hans Passant
    Mar 7 at 15:54











  • @MarcGravell, it is a third party thing, called by National Instruments TestStand passing an Array of Numbers (Int32). Unfortunately, we'd like to move away from TestStand, so I'm trying to call it from a c# app, instead. Under all points of view, I don't see it changing soon, I can't get hold of the developer/maintainer, so it is sealed third party for me.

    – Daemon Painter
    Mar 7 at 16:04












  • @MarcGravell, the dynamic solution is reporting this, instead: Unable to cast object of type 'System.Int32[*]' to type 'System.Int32[]'.

    – Daemon Painter
    Mar 7 at 16:20








1




1





exposing an API with a non-vector typed array is ... just asking for pain. That isn't a thing that you can cleanly express in C#; what is NAMESPACE.myFunction? is this a third party thing? can you change the signature, or request it be changed?

– Marc Gravell
Mar 7 at 15:47






exposing an API with a non-vector typed array is ... just asking for pain. That isn't a thing that you can cleanly express in C#; what is NAMESPACE.myFunction? is this a third party thing? can you change the signature, or request it be changed?

– Marc Gravell
Mar 7 at 15:47





1




1





note: if the API is instance based, not static based, you might be able to cheat by using dynamic...

– Marc Gravell
Mar 7 at 15:48





note: if the API is instance based, not static based, you might be able to cheat by using dynamic...

– Marc Gravell
Mar 7 at 15:48




1




1





You can't keep the C# compiler happy. Use ildasm.exe to decompile the assembly, edit the IL and change the argument to Array, put it back together with ilasm.exe. If this is likely to change soon then you do want to contact the author to get this right.

– Hans Passant
Mar 7 at 15:54





You can't keep the C# compiler happy. Use ildasm.exe to decompile the assembly, edit the IL and change the argument to Array, put it back together with ilasm.exe. If this is likely to change soon then you do want to contact the author to get this right.

– Hans Passant
Mar 7 at 15:54













@MarcGravell, it is a third party thing, called by National Instruments TestStand passing an Array of Numbers (Int32). Unfortunately, we'd like to move away from TestStand, so I'm trying to call it from a c# app, instead. Under all points of view, I don't see it changing soon, I can't get hold of the developer/maintainer, so it is sealed third party for me.

– Daemon Painter
Mar 7 at 16:04






@MarcGravell, it is a third party thing, called by National Instruments TestStand passing an Array of Numbers (Int32). Unfortunately, we'd like to move away from TestStand, so I'm trying to call it from a c# app, instead. Under all points of view, I don't see it changing soon, I can't get hold of the developer/maintainer, so it is sealed third party for me.

– Daemon Painter
Mar 7 at 16:04














@MarcGravell, the dynamic solution is reporting this, instead: Unable to cast object of type 'System.Int32[*]' to type 'System.Int32[]'.

– Daemon Painter
Mar 7 at 16:20






@MarcGravell, the dynamic solution is reporting this, instead: Unable to cast object of type 'System.Int32[*]' to type 'System.Int32[]'.

– Daemon Painter
Mar 7 at 16:20













0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047532%2fcannot-convert-from-system-array-to-int%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047532%2fcannot-convert-from-system-array-to-int%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved