C# Eval Expression - LINQ Dynamic - EqualAll

LINQ Dynamic EqualAll Examples

C# Dynamic LINQ EqualAll examples using an Expression Evaluator.

EqualAll - 1

This C# example uses the LINQ EqualAll method with a dynamic expression to see if two sequences match on all elements in the same order.

LINQ

private void uiEqualAll_1_LINQ_Click(object sender, EventArgs e)
{
	var wordsA = new[] {"cherry", "apple", "blueberry"};
	var wordsB = new[] {"cherry", "apple", "blueberry"};

	var match = wordsA.SequenceEqual(wordsB);

	var sb = new StringBuilder();

	sb.AppendLine("The sequences match: {0}", match);

	My.Result.Show(My.LinqResultType.Linq, uiResult, sb);
}

LINQ Execute

private void uiEqualAll_1_LINQ_Execute_Click(object sender, EventArgs e)
{
	var wordsA = new[] {"cherry", "apple", "blueberry"};
	var wordsB = new[] {"cherry", "apple", "blueberry"};

	var match = wordsA.Execute<bool>("SequenceEqual(wordsB)", new {wordsB});

	var sb = new StringBuilder();

	sb.AppendLine("The sequences match: {0}", match);

	My.Result.Show(My.LinqResultType.LinqExecute, uiResult, sb);
}

Result

LINQ Execute Test
------------------------------
The sequences match: True

EqualAll - 2

This C# example uses the LINQ EqualAll method with a dynamic expression to see if two sequences match on all elements in the same order.

LINQ

private void uiEqualAll_2_LINQ_Click(object sender, EventArgs e)
{
	var wordsA = new[] {"cherry", "apple", "blueberry"};
	var wordsB = new[] {"apple", "blueberry", "cherry"};

	var match = wordsA.SequenceEqual(wordsB);

	var sb = new StringBuilder();

	sb.AppendLine("The sequences match: {0}", match);

	My.Result.Show(My.LinqResultType.Linq, uiResult, sb);
}

LINQ Execute

private void uiEqualAll_2_LINQ_Execute_Click(object sender, EventArgs e)
{
	var wordsA = new[] {"cherry", "apple", "blueberry"};
	var wordsB = new[] {"apple", "blueberry", "cherry"};

	var match = wordsA.Execute<bool>("SequenceEqual(wordsB)", new {wordsB});

	var sb = new StringBuilder();

	sb.AppendLine("The sequences match: {0}", match);

	 My.Result.Show(My.LinqResultType.LinqExecute, uiResult, sb);
}

Result

LINQ Execute Test
------------------------------
The sequences match: False