using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace MyApp
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt1 = new DataTable();
dt1.Columns.Add("Bay", typeof(string));
dt1.Rows.Add("S30");
dt1.Rows.Add("S31");
//dt1.Rows.Add("S32");
DataTable dt2 = new DataTable();
dt2.Columns.Add("Bay", typeof(string));
dt2.Rows.Add("S31");
dt2.Rows.Add("S41");
dt2.Rows.Add("S51");
var vardt1 = dt1.AsEnumerable().Select(a => a.Field<string>("Bay"));
var vardt2 = dt2.AsEnumerable().Select(a => a.Field<string>("Bay"));
var varUnMatched = vardt1.Except(vardt2);
Response.Write(varUnMatched.Count().ToString()+"<br/>");
foreach (var element in varUnMatched)
{
Response.Write(element + "<br/>");
}
}
}
}
Cheers!!!
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace MyApp
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt1 = new DataTable();
dt1.Columns.Add("Bay", typeof(string));
dt1.Rows.Add("S30");
dt1.Rows.Add("S31");
//dt1.Rows.Add("S32");
DataTable dt2 = new DataTable();
dt2.Columns.Add("Bay", typeof(string));
dt2.Rows.Add("S31");
dt2.Rows.Add("S41");
dt2.Rows.Add("S51");
var vardt1 = dt1.AsEnumerable().Select(a => a.Field<string>("Bay"));
var vardt2 = dt2.AsEnumerable().Select(a => a.Field<string>("Bay"));
var varUnMatched = vardt1.Except(vardt2);
Response.Write(varUnMatched.Count().ToString()+"<br/>");
foreach (var element in varUnMatched)
{
Response.Write(element + "<br/>");
}
}
}
}
Cheers!!!
No comments:
Post a Comment