Closed Tavernari closed 8 years ago
Can you give me a little more background on what this is solving?
Also, would using the .ToList() method on the array be a clearer way of handling this or is there something about creating a list and adding the elements that makes the casting work properly?
I had a problem with UnityHTTP when I pass an array like int[]
, because int is generic type and not object
.
In my code I had List<int> score = new List<int>();
and in final of implementation I did score.ToArray()
and this return int[]
.
To resolve it I used List<object> score = new List<object>();
score.Add(10);
score.ToArray();
now return object[]
.
And I thought do it every time in UnityHTTP to help others with same problem.
Thanks Advance Victor
I am interested in merging this, but would this work as well?:
} else if(value.GetType().IsArray) {
List<object> values = value.ToList();
success = SerializeArray(values.ToArray(), builder);
} else {
Or must you do the Add() method to get things to cast?
(I don't use this library anymore, but I try to accept patches. If you think there's no better or shorter way to do what this patch accomplishes, I will still accept it, I just want to make sure the code is as short and clear as possible.)
@Tavernari ping
Sorry delay @andyburke !
I looked for solution in my work project and I feel this modification is not necessary. I am working with Hashtables and Arraylist.
Please and sorry but I had more trouble when try generic cast.
I am doing object cast in my side manually.
Don't merge it! Work some time but I think it will very sensitive to future bugs.
Great Job @andyburke !
Ok, closing for now, but open to any future ideas on this.
Exception about cast other type to object[] crash the app.