Mapster
Mapster copied to clipboard
Adapt to array does not work
var v_int1 = 1;
var v1_= v_int1.Adapt<int[]>();//error :“Invalid cast from 'System.Int32' to ...
var v1_2 = v_int1.Adapt<List<int>>().Adapt<int[]>();//ok
Hm, this should indeed work. I'll add a regression test for this and see if I can pinpoint where things go wrong.
@HZ-GeLiang
You wanted to initialize an array for one element typeof int - int[1] or new int[1] { 1 } ?
Now this get
var v1_2 = v_int1.Adapt<List
>().Adapt<int[]>();//ok
you get int[0] - empty array for Type int
@HZ-GeLiang You wanted to initialize an array for one element typeof int - int[1] or new int[1] { 1 } ? Now this get
var v1_2 = v_int1.Adapt<List>().Adapt<int[]>();//ok
you get int[0] - empty array for Type int
I want is new int [1]{1}
If possible, I would like the result to be:
v_int1.Adapt<List
new List<int>();
v_int1.Adapt<int[]>() // returns new int[] { 1 }
Seems like from Array is work from this algorithm
1.Adapt<List
- Inside member of Int is not possible to create any of the available constructors for the List,
- create new List() is created.