title: How to retrieve Distinct string values from comparing two Arrays?
body: <p>I want to retrieve Absent student names from sql database.
  I have a Listbox in which i have Present student Rfid data (Something like 42 39 A0 11), I have stored the student details along with Rfid in database as nvarchar(1500) datatype.</p>
  
  <p>Using the present stud id in list box i want to retrieve absent students name in an List.</p>
  
  <p>Then i thought of using foreach loop to remove the students who's id was in the Listbox</p>
  
  <p>But when i defined the two list like total and present with values and tried to remove the string from total which are in present the nthe output was successful</p>
  
  <pre><code>private void checkabst_Click(object sender, EventArgs e)
          {
              string[] present1 = new string[listbox_present.Items.Count];
              List&lt;string&gt; present = new List&lt;string&gt; { ""};
              List&lt;string&gt; absent = new List&lt;string&gt;();
              List&lt;string&gt; total = new List&lt;string&gt;();
              using (SqlConnection con = new SqlConnection(cs))
              {
                  SqlCommand cmd = new SqlCommand("Select Rfid_Uid From Studetails", con);
                  con.Open();
                  SqlDataReader sdr = cmd.ExecuteReader();
  
                  while (sdr.Read())
                  {
                      total.Add(sdr[0].ToString());
                  }
              }
             present = listbox_present.Items.Cast&lt;string&gt;().ToList();
  
              foreach(string temp in present)
              {
                  total.Remove(temp);
              }
  
              foreach (string temp in total)
              {
                  listbox_absent.Items.Add(temp);
              }
          }
  </code></pre>
  
  <p>Stuck here from past few days.</p>
  
  <p>The problem i think the listbox values are giving trouble while removing the string from total list.</p>