How does one convert C# List<byte> to NSData?

Viewed 190

I'm working on a Xamarin Forms app (don't ask) and have to write platform-specific code for the iOS solution. I'm primarily an iOS developer, so my C# is lacking in certain areas.

The iOS CBPeripheral.WriteValue call requires an NSData object.

I currently have a C# List data structure. So I need to convert that to NSData in order to write the value.

I've searched on the usual candidates (S.O., etc,) but haven't found a solution to my particular problem.

I'd appreciate any help people can provide.

1 Answers

if MyList is a List<byte>

var arr = MyList.ToArray<byte>();
var data = NSData.FromArray(arr)
Related