Просто добавьте вверху вашего кода следующую строку
from random import randrange, randint
С.NET 3.5:
using System.Data;
public static class DataTableExtensions
{
public static IEnumerable<DataRow> Intersect(this DataTable table, DataTable other)
{
return table.AsEnumerable().Intersect(other.AsEnumerable());
}
public static IEnumerable<DataRow> Intersect(this DataTable table, DataTable other, IEqualityComparer<DataRow> comparer)
{
return table.AsEnumerable().Intersect(other.AsEnumerable(), comparer);
}
}
Видел этот пример на MSDN, которого можно найти полезным. Его использование синтаксиса LINQ.
DataSet ds = new DataSet();
ds.Locale = CultureInfo.InvariantCulture;
FillDataSet(ds);
DataTable orders = ds.Tables["SalesOrderHeader"];
DataTable details = ds.Tables["SalesOrderDetail"];
var query =
from order in orders.AsEnumerable()
join detail in details.AsEnumerable()
on order.Field<int>("SalesOrderID") equals
detail.Field<int>("SalesOrderID")
where order.Field<bool>("OnlineOrderFlag") == true
&& order.Field<DateTime>("OrderDate").Month == 8
select new
{
SalesOrderID =
order.Field<int>("SalesOrderID"),
SalesOrderDetailID =
detail.Field<int>("SalesOrderDetailID"),
OrderDate =
order.Field<DateTime>("OrderDate"),
ProductID =
detail.Field<int>("ProductID")
};
foreach (var order in query)
{
Console.WriteLine("{0}\t{1}\t{2:d}\t{3}",
order.SalesOrderID,
order.SalesOrderDetailID,
order.OrderDate,
order.ProductID);
}
Так как Вы используете.NET 2.0, необходимо посмотреть на перереализацию Пересечь метода.