In order to access comport you need to have namespace
using System.IO.Ports;
then in button click event write this
{
then need to create an object for serial port like this
SerialPort obj = new SerialPort("COM1");
obj.Open();
string a = obj.ReadExisting();
obj.Close();
MessageBox.Show(a);
}
Hope this may help you