shay a

shay a

  • NA
  • 70
  • 4k

check substring in string returned from serialport c#

Mar 15 2022 8:07 PM

Hello friends,

i have a code to read values from a serial port:

private static void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
        {
            
            if (Startint == true)
            {

                string DataIn = serialPort1.ReadExisting();
                
                if (DataIn.Contains("Copyright"))
                {
                        Console.Write(DataIn); 
                                        }
                
                
            }
                      
        }

the string received from the port definitely contains the substring "Copyright" but for some reason the Linq contains is not working.

any ideas?

thank you.


Answers (2)