0

I want to compare string received from UART and compare with each row in a specific column in GUI.

Is this the correct way to do it?

private void compare()
{
    int i;
    DataSet ds = new DataSet();
    compareString = serialPort.Read();    //receive string from UART

    while(1){
        if(compareString == ds.Tables[0].Rows[i][3].ToString())
        {doorOpen();}
        else {continue;}
        i++;
    }
}
  • The code posted as sample does not seem to be related to the question - there is no comparisons between any values. Checking how to [C# compare strings](https://www.bing.com/search?q=c%23+compare+strings) may be good starting point to clarify question. – Alexei Levenkov Sep 07 '15 at 00:49
  • I have made modification tq :) – Nabil Fikri Sep 07 '15 at 00:54
  • Does this code provide result you want? - than it is correct (you may want to post code in this case to CodeReview SE to get comments). If it does not provide results you want - have you debugged it? Also consider existing questions like http://stackoverflow.com/questions/20638351/find-row-in-datatable-with-specific-id which show existing ways to find row by property. – Alexei Levenkov Sep 07 '15 at 01:03
  • Alright thanks. I found the answer that I need from the link given. Thanks again – Nabil Fikri Sep 07 '15 at 01:11

0 Answers0