Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Convert string to array of Uint16

happy new year !

I have collected data from an OPC UA server, the data is :

0;0;0;0;0;

I need to write this data to my OPC UA server, the good syntax need to be :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

UInt16[] temp = { 0, 0, 0, 0, 0 };

How can I convert the first string to have my array of Uint16 ?

>Solution :

Using linq :

var dataString = "0;0;0;0;0;";
var temp = dataString.Split(';')
           .Where(s => !s.Equals(string.Empty))
           .Select(value => Convert.ToUInt16(value))
           .ToArray();

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading