Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am interfacing matlab dll in wpf c# application. While converting Byte Array to MWArray it is giving Exception like

Unable to cast object of type 'System.Byte[]' to type 'System.IConvertible'

What I have tried:

//result is a Byte Array
MWArray objectarray= Convert.ToUInt16(result);
Posted
Updated 24-Feb-17 22:33pm

1 solution

You can't convert a byte array to an integer like that. You need to use a BitConverter: How to: Convert a byte Array to an int (C# Programming Guide)[^]

Here is a link with more information: How to add elements in MWarray from C# ms visual 2010 - MATLAB Answers - MATLAB Central[^]
 
Share this answer
 
v2
Comments
Member 11559270 25-Feb-17 5:06am    
ok you forget about my conversion... i need generic conversion from byte array to MWArray
Graeme_Grant 25-Feb-17 5:07am    
Are you expecting me to write it for you? Click on the links provided. There is more than enough information there to explain how to do it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900