SMSCOMMS SMSEngine = new SMSCOMMS("COM6");
The code doesn’t seem to take my argument of COM6 as a valid ref string.How can I solve this?
public class SMSCOMMS
{
public SMSCOMMS(ref string COMMPORT)
{
SMSPort = new SerialPort();
SMSPort.PortName = COMMPORT;
SMSPort.BaudRate = 9600;
SMSPort.Parity = Parity.None;
SMSPort.DataBits = 8;
SMSPort.StopBits = StopBits.One;
SMSPort.Handshake = Handshake.RequestToSend;
SMSPort.DtrEnable = true;
SMSPort.RtsEnable = true;
SMSPort.NewLine = System.Environment.NewLine;
ReadThread = new Thread(
new System.Threading.ThreadStart(ReadPort));
}
You can’t pass a temporary with
ref, because the called method must be able to assign to the caller’s variable. Why are you using it to begin with? You never assign toCOMMPORT.Why not just: