title: How to compare two DataSet using HashSet in asp.net c#
body: <p>I am adding two tables to a DataSet and I want to check if they are equal.</p>
  
  <p>The code I have tried is :</p>
  
  <pre><code>SqlDataAdapter mydat = new SqlDataAdapter("Select Device_Profile_Param+'='+Device_Profile_Default_Value AS SettingsCheck From Device_Profile_Master Where Device_Profile_Name = '" + Label5.Text + "'", con); 
  DataTable dt = new DataTable(); 
  mydat.Fill(dt);
  
  DataSet dset = new DataSet();
  dset.Tables.Add(dt);
  
  SqlDataAdapter mydata = new SqlDataAdapter("Select Device_Profile_Param+'='+Device_Profile_Default_Value AS Settings From Device_Profile_Master Where Device_Profile_Name = '" + For_Profile_Num.Items[i] + "'", con);
  DataTable dt2 = new DataTable();
  mydata.Fill(dt2);
  
  dset.Tables.Add(dt2);
  
  var hashSet1 = new HashSet&lt;string&gt;(dset.Tables[0].Rows.Cast&lt;ListItem&gt;().Select(x =&gt; x.Value));
  var hashSet2 = new HashSet&lt;string&gt;(dset.Tables[1].Rows.Cast&lt;ListItem&gt;().Select(x =&gt; x.Value));
  
  var result = hashSet1.SetEquals(hashSet2);
  if (result == true)
  {
  found = 1;
  }
  </code></pre>
  
  <p>I am getting a error <strong>DataSet cannot be cast as ListItem</strong>. Kindly help.</p>