question

Ozan Yilmaz avatar image
Ozan Yilmaz asked

How to convert JS array to C# array?

Hello everyone,

There is a functions that returns [1,1,0,0,1] in the cloudscript. I want to convert this data into C# boolean array. How can I do this?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Seth Du avatar image
Seth Du answered

I can say all roads lead to Rome. You can search online for more methods but here is my solution.

I assume you will receive a PlayFab JsonArray like [1,0,1,0,1]:

char[] charsforTrim = {'[', ']' }; 
var strings = onSuccessCallback.FunctionResult.ToString().Trim(charstoTrim).Split(','); 
var bools = new BitArray(Array.ConvertAll(a,int.Parse)).Cast<bool>().ToArray();
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.