Main Content


Generic .NET Dictionary

Since R2023a



    netDict = NET.createDictionary(mlDict) creates a generic .NET dictionary from a MATLAB® dictionary.


    collapse all

    Create a MATLAB dictionary with two numeric entries. Convert the dictionary to use in .NET functions.

    mlDict = dictionary("entry 1",3.14,"entry 2",42);
    netDict = NET.createDictionary(mlDict)
    netDict = 
      Dictionary<System*String,System*Double> with properties:
        Comparer: [1×1 System.Collections.Generic.GenericEqualityComparer<System*String>]
           Count: 2
            Keys: [1×1 System.Collections.Generic.Dictionary*KeyCollection<System*String,System*Double>]
          Values: [1×1 System.Collections.Generic.Dictionary*ValueCollection<System*String,System*Double>]

    Input Arguments

    collapse all

    Configured MATLAB dictionary, specified as a dictionary.

    Example: "entry 1",3.14,"entry 2",42

    Output Arguments

    collapse all

    .NET dictionary, returned as an instance of System.Collections.Generic.Dictionary<TKey, TValue> with equivalent entries as mlDict. The generic parameters are the .NET types that most closely match the types of keys and values in the MATLAB dictionary. For information about type conversions, see Pass Data to .NET Objects.

    Version History

    Introduced in R2023a

    expand all