Skip to content

Commit 0f4599c

Browse files
committed
Update README.md
1 parent 452818e commit 0f4599c

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

README.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,38 @@ julia> DotNET.unbox(s)
8989
""
9090
```
9191

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+
92114
### Arrays and Collections
93115

94116
To copy a multidimensional array from `.NET` to Julia, use `collect` method:
95117

96118
```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[,,]")
99121

100122
julia> collect(arr)
101-
2×2×2 Array{Int32, 3}:
123+
2×2×2 Array{Int64, 3}:
102124
[:, :, 1] =
103125
1 3
104126
2 4
@@ -110,8 +132,8 @@ julia> collect(arr)
110132

111133
CLI `Array` elements are stored in *row-major* order, thus the equivalent definition in `C#` is
112134
```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] {
115137
{{1, 2}, {3, 4}},
116138
{{5, 6}, {7, 8}}
117139
};

0 commit comments

Comments
 (0)