Union,Except and Intersect operator in Linq

char[] delimiters = new char[] { '\n', '\r', ',' };
                string[] strNewValue = txtvalue.Text.Trim().Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
                string OldString = ViewState["OldMisspell"].ToString();
                string[] strOld = OldString.Trim().Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

                DataTable dtMissingValue = new DataTable();
                dtMissingValue.Columns.Add("ColumnName", typeof(string));
                dtMissingValue.Columns.Add("ColumnName ", typeof(string));
                dtMissingValue.Columns.Add("ColumnName ", typeof(int));
                dtMissingValue.Columns.Add("ColumnName ", typeof(bool));

      var vDeleteingValues = OldString.Except(strNewValue).Select(s => new { ColumnName = s, ColumnName = 1 });
      var vNewValues = strNewValue.Except(strOld).Select(a => new { ColumnName = a, ColumnName = 0 });
      var vOldValues = strNewValue.Intersect(strOld).Select(s => new { ColumnName = s, ColumnName = 0 });

                var vBindingData = vNewValues.Union(vOldValues).Union(vDeleteingValues);
                foreach (var item in vBindingData
                {
                    DataRow dtrow = dtMissingValue.NewRow();
                    dtrow["Domain"] = txt.Text;
                    dtrow["Misspellvalue"] = item.ColumnName;
                    dtrow["CreatedBy"] = ID;
                    dtrow["IsHidden"] = item.ColumnName;
                    dtMissingValue.Rows.Add(dtrow);
                }

Comments