This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Documentation / Mathematica / Add-ons & Links / .NET/Link / Part 1. Calling .NET from Mathematica: 'Installable .NET' /

Conversion of Types Between .NET and Mathematica

Before we encounter the operations of creating .NET objects and calling methods, we should examine the mapping of types between Mathematica and .NET. When a .NET method returns a result to Mathematica, the result is automatically converted into a Mathematica expression. For example, .NET integer types (e.g., Int32, Byte, and so on), are converted into Mathematica integers, and .NET real number types (Single, Double) are converted into Mathematica reals. The table below shows the complete set of conversions. These conversions work both ways—for example, when a Mathematica integer is sent to a .NET method that requires a Byte value, the integer is automatically converted to a .NET Byte.

Note that this table gives type names as they are used in the .NET Framework. Different languages often have their own keywords that map to these underlying types. In C#, for example, the keyword int is an alias to the Int32 type, and in Visual Basic .NET the Int32 type is called Integer.

Corresponding types in .NET and Mathematica.

.NET arrays are mapped to Mathematica lists of the appropriate depth. Thus, when you call a method that takes a double[] (in C# notation), you might pass it {1.0, 2.0, N[Pi], 1.23}. Similarly, a method that returns a two-deep array of integers (int[,] in C# notation) might return to Mathematica the expression {{1, 2, 3}, {5, 3, 1}}.