MAXScript Tools and Interaction with 3ds Max > DotNet In MAXScript >

# MAXScript / DotNet Value Conversions

MAXScript will automatically convert its native values to DotNet values and DotNet values to MAXScript values.

In addition, value conversion can be performed explicitly using a dedicated function in 3ds Max 2010 and higher.

### Automatic Conversion

The following table shows the native MAXScript value types and the DotNet value types they can be converted to in 3ds Max 9 and higher.

MAXScript type | DotNet type
    Integer, Integer64, IntegerPtr, Float, Double, MSTime
    Byte, SByte, Decimal, Int16, UInt16, Int32, UInt32, IntPtr, UIntPtr, Int64, UInt64, Single, Double
    Boolean
    Boolean
    String
    String, Char array

The following table shows the DotNet value types and the native MAXScript value type they are converted to.

DotNet type | MAXScript type
    Byte, SByte, Decimal, Int16, UInt16, Int32, UInt32
    Integer
    Int64, UInt64
    Integer64
    IntPtr, UIntPtr
    IntegerPtr
    Single
    Float
    Double
    Double
    Boolean
    Boolean
    String, Char array
    String

### Explicit Conversion

The following method performs a conversion of a MAXScript value to a DotNet value.

Available in 3ds Max 2010 and higher.

    dotNet.ValueToDotNetObject <value> { <dotNetClass> | <dotNetObject> }

Returns a dotNetObject value where the MAXScript value passed as first argument is converted to a DotNet object of the type specified by the second argument.

This allows for the easy creation of DotNet arrays from MAXScript arrays:

EXAMPLE
    type = dotNetClass "System.Int32[]"
    dotNetClass:System.Int32[]
    res = dotnet.ValueToDotNetObject #(11,12,23) type
    dotNetObject:System.Int32[]
    res.length
    3
    res.getvalue 2 --DotNet arrays arezero-based!
    23

#### See Also

- DotNet In MAXScript