Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for System.Double #3

Closed
bradcarman opened this issue Sep 1, 2020 · 2 comments
Closed

Support for System.Double #3

bradcarman opened this issue Sep 1, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@bradcarman
Copy link

bradcarman commented Sep 1, 2020

It seems System.Double is currently not supported. I have a class that returns a 2D double matrix (System.Double[,]) that I would like to retrieve in Julia. Is this currently possible or does It need to be added to the package?

@azurefx
Copy link
Owner

azurefx commented Sep 1, 2020

Yes it was not supported and I think it's necessary. Added in #4 .
DotNET.jl doesn't have array access syntax for CLR objects yet, however you can use Get/SetValue methods as an alternative.

julia> using DotNET

julia> arr=T"System.Array".CreateInstance(T"System.Double",3,4)
System.Double[,]("System.Double[,]")

julia> arr.Length
12

julia> arr.GetLength(Int32(0))
3

julia> arr.GetLength(Int32(1))
4

julia> for r=0:2
           for c=0:3
               arr.SetValue(1+r+c*3,r,c)
           end
       end

julia> permutedims(reshape(collect(arr),4,3))
3×4 Array{Float64,2}:
 1.0  4.0  7.0  10.0
 2.0  5.0  8.0  11.0
 3.0  6.0  9.0  12.0

@bradcarman
Copy link
Author

Thanks! This is working for me, feel free to close.

@azurefx azurefx closed this as completed Oct 16, 2020
@azurefx azurefx added the bug Something isn't working label Mar 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants