A
A
AlecT2021-05-28 00:01:23
Arduino
AlecT, 2021-05-28 00:01:23

Parsing in C# (VisualStudio2019)?

I am quite new to C#.
Data from sensors is transmitted from Arduino to the Serial port in the format: 0, sensor reading 1,1, sensor reading 2, ... (index, terminator, value).
In VisualStudio2019 a form is created on it's label1...etc.
it is necessary to write in label1 only the reading of sensor1, in label2 write only the reading of sensor2, etc.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-05-28
@vabka

0,показ.датчика1,1,показания датчика2,...
It appears to be CSV.
Parsing it is terribly easy:

var values = "0,123.5,1,456.25".Split(',');
var firstSensorValue = double.Parse(values[1]);
var secondSensorValue = double.Parse(values[3]);

And then shove them into your labels.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question