Re: .NET/Link: Explicitly define data type to be sent to .NET object?
- To: mathgroup at smc.vnet.net
- Subject: [mg85766] Re: .NET/Link: Explicitly define data type to be sent to .NET object?
- From: heiko <heiko.damerau.news at web.de>
- Date: Thu, 21 Feb 2008 18:03:31 -0500 (EST)
- References: <email@example.com>
Hello, Thanks a lot for the suggestion to my NETLink problem. In the meantime I was pointed to a very nice solution to the type conversion problem: To transfer e.g. an integer (Mathematica) value into Byte (C++) format, one can first create a .NET object of System.Byte. The value from Mathematica is then sent to this object, being a Byte variable in C++ and thus forcing the correct type conversion from Mathematica Integer to Byte. Finally, the System.Byte object is sent to the (in my case) overloaded insert(...) method. By choosing an appropriate type of the intermediate object, one can thus select which specific method (from the list of overloaded methods with same name and arguments) will be executed. Best regards, Heiko On 19 f=E9v, 08:01, heiko <heiko.damerau.n... at web.de> wrote: > Hello, > > To get some data from Mathematica to a .NET object, I need to > avoid confusion between different integer or real data types in > Mathematica and C++. Is it somehow possible to explicitly define the > type of a variable being sent from Mathematica to C++? > > Some more detailed description of the problem: The .NET object > contains several overloaded methods for different data types, e.g. > void insert(SByte value), void insert(Int16 value), void insert(Int32 > value), void insert(Int64 value), etc. When I now send integer data > from Mathematica to the object using object at insert[...] the data is > apparently always sent to the insert(Int64 value) method; even if the > integer in Mathematica only contains a value from 0 to 255. This is, > however, not the method I need to call, but e.g. void insert(SByte > value). As I haven't written the .NET library myself, I cannot just > change the names of the methods inside. > > How can I tell .NET/Link in Mathematica that I want the integer/ > real data in Mathematica to be transferred to a specific integer or > real data type in C++? > > Thanks a lot in advance for any help! > > Best regards, > Heiko