@@ -89,16 +89,38 @@ julia> DotNET.unbox(s)
89
89
" ❤"
90
90
```
91
91
92
+ To pass an argument by reference (` out ` /` ref ` in ` C# ` ), wrap it into a ` Ref ` object:
93
+
94
+ ``` julia
95
+ julia> result = Ref {Int} ()
96
+ Base. RefValue {Int64} (212700848 )
97
+
98
+ julia> T " System.Int64" . TryParse (" 1970" , result)
99
+ true
100
+
101
+ julia> result[]
102
+ 1970
103
+
104
+ julia> result = Ref (null)
105
+ Base. RefValue {CLRObject} (null)
106
+
107
+ julia> T " System.Int64" . TryParse (" 2022" , result)
108
+ true
109
+
110
+ julia> result[]
111
+ System. Int64 (2022 )
112
+ ```
113
+
92
114
### Arrays and Collections
93
115
94
116
To copy a multidimensional array from ` .NET ` to Julia, use ` collect ` method:
95
117
96
118
``` julia
97
- julia> arr = convert (CLRObject, reshape (UnitRange {Int32} ( 1 , 8 ) , 2 , 2 , 2 ))
98
- System. Int32 [,,](" System.Int32 [,,]" )
119
+ julia> arr = convert (CLRObject, reshape (1 : 8 , 2 , 2 , 2 ))
120
+ System. Int64 [,,](" System.Int64 [,,]" )
99
121
100
122
julia> collect (arr)
101
- 2 × 2 × 2 Array{Int32 , 3 }:
123
+ 2 × 2 × 2 Array{Int64 , 3 }:
102
124
[:, :, 1 ] =
103
125
1 3
104
126
2 4
@@ -110,8 +132,8 @@ julia> collect(arr)
110
132
111
133
CLI ` Array ` elements are stored in * row-major* order, thus the equivalent definition in ` C# ` is
112
134
``` csharp
113
- public static int [,,] Get3DArray () {
114
- return new int [2 , 2 , 2 ] {
135
+ public static long [,,] Get3DArray () {
136
+ return new long [2 , 2 , 2 ] {
115
137
{{1 , 2 }, {3 , 4 }},
116
138
{{5 , 6 }, {7 , 8 }}
117
139
};
0 commit comments