Query
public void Linq98() {
int[] vectorA = { 0, 2, 4, 5, 6 };
int[] vectorB = { 1, 3, 5, 7, 8 };
int dotProduct = vectorA.Combine(vectorB, (a, b) => a * b).Sum();
Console.WriteLine("Dot product: {0}", dotProduct);
}
Lambda Expression
public void DataSetLinq98()
{
var numbersA = testDS.Tables["NumbersA"].AsEnumerable();
var numbersB = testDS.Tables["NumbersB"].AsEnumerable();
int dotProduct = numbersA.Combine(numbersB, (a, b) => a.Field("number") * b.Field("number")).Sum();
Console.WriteLine("Dot product: {0}", dotProduct);
}