You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
is not going to work. I don't think anyone is using this overload much, which is why it hasn't come up, but the code as is will definitely not populate the C# array with the contents of the C++ array representing the sample. No exception or compiler warning will be issued, but the char[] sample variable on the C# side will always contain 0s. The reason is that in C# a char is not a primitive type, but rather an object that can be either 1 or 2 bytes depending on how it is encoded. Thus, this pointer won't marshal properly from managed to unmanaged code and the contents will simply retain their default initialization values.
The correct way to do this is to use byte[] on the C# side and then convert it to a char array like so: char[] sample = System.Text.Encoding.ASCII.GetString(byte_sample).ToCharrArray()'
The same issue will occur with pull_chunk(char[,]...)
I don't know if this really matters. I can't see why anyone would need this overload in the C# wrapper. The overload with string works just fine.
The text was updated successfully, but these errors were encountered:
This is just a heads up as I ran into this problem in a different project.
Without testing it, I can say for sure that this:
liblsl-Csharp/LSL.cs
Line 572 in c74a4d4
char[] sample
variable on the C# side will always contain 0s. The reason is that in C# achar
is not a primitive type, but rather an object that can be either 1 or 2 bytes depending on how it is encoded. Thus, this pointer won't marshal properly from managed to unmanaged code and the contents will simply retain their default initialization values.The correct way to do this is to use
byte[]
on the C# side and then convert it to a char array like so:char[] sample = System.Text.Encoding.ASCII.GetString(byte_sample).ToCharrArray()'
The same issue will occur with
pull_chunk(char[,]...)
I don't know if this really matters. I can't see why anyone would need this overload in the C# wrapper. The overload with
string
works just fine.The text was updated successfully, but these errors were encountered: