I have a string array I need to convert to byte[][] (to connect Xcode with Unity scripts in C#).
This is the functions in Xcode:
void doThisC(char** matrix);
And in Unity in C#, this is what I have but I’m not able to make it work:
public static void doThis(string[] array, int size){
char[][] grid = new char[][] { new char[size] , new char[100]};
byte[][] buffer;
for(int i = 0 ; i < size ; i++)
{
grid[i] = array[i].ToString().ToCharArray();
buffer[i] = (new System.Text.UTF8Encoding()).GetBytes(grid[i]);
}
doThisC(buffer);
}
The
gridarray only has two items, so the code will only work up to two strings. You don’t need thegridarray at all. Also, you don’t create the arraybuffer:or using Linq extension methods: