The first error is because of this: Array myPort;
. That’s not how you declare an array, Array
is an abstract class that provides methods to operate on arrays. SerialPort.GetPortNames()
returns a string array so you can either declare a string array or just remove the Array myPort;
declaration and replace the other line with
var myPort = System.IO.Ports.SerialPort.GetPortNames();
.
The next issue is with float i = serialPort1.ReadExisting;
, it’s a method so you have to invoke it i.e. serialPort1.ReadExisting()
. I think that method has a return type of string so you don’t need to make it a float either, it looks like you’re using it as a string in the next line anyway so i
doesn’t have to be a float.
The other errors are because you are trying to assign a combobox selected item to int and string values but a selected item is an object, you have to cast it to the desired type e.g.
serialPort1.BaudRate = (int)cmbBaud.SelectedItem;
0
solved Cannot implicitly convert type ‘object’ to ‘int’. An explicit conversion error exists