@@ -18,34 +18,22 @@ This C# example uses the LINQ Aggregate method with a dynamic expression to crea
1818
1919### LINQ
2020{% highlight csharp %}
21- private void uiAggregate_Simple_LINQ_Click(object sender, EventArgs e)
22- {
23- double[ ] doubles = {1.7, 2.3, 1.9, 4.1, 2.9};
21+ double[ ] doubles = {1.7, 2.3, 1.9, 4.1, 2.9};
2422
25- var product = doubles.Aggregate((runningProduct, nextFactor) => runningProduct * nextFactor);
23+ var product = doubles.Aggregate((runningProduct, nextFactor) => runningProduct * nextFactor);
2624
27- var sb = new StringBuilder();
28-
29- sb.AppendLine("Total product of all numbers: {0}", product);
30-
31- My.Result.Show(My.LinqResultType.Linq, uiResult, sb);
32- }
25+ Console.WriteLine("Total product of all numbers: {0}", product);
3326{% endhighlight %}
27+ {% include component-try-it.html href='https://dotnetfiddle.net/BZLbt5 ' %}
3428
3529### LINQ Execute
3630{% highlight csharp %}
37- private void uiAggregate_Simple_LINQ_Execute_Click(object sender, EventArgs e)
38- {
39- double[ ] doubles = {1.7, 2.3, 1.9, 4.1, 2.9};
40-
41- var product = doubles.Execute<double>("Aggregate((runningProduct, nextFactor) => runningProduct * nextFactor)");
42-
43- var sb = new StringBuilder();
31+ double[ ] doubles = {1.7, 2.3, 1.9, 4.1, 2.9};
4432
45- sb.AppendLine("Total product of all numbers: {0}", product );
33+ var product = doubles.Execute< double >("Aggregate((runningProduct, nextFactor) => runningProduct * nextFactor)" );
4634
47- My.Result.Show(My.LinqResultType.LinqExecute, uiResult, sb );
48- }
35+ Console.WriteLine("Total product of all numbers: {0}", product );
36+ {% include component-try-it.html href=' https://dotnetfiddle.net/HbOEOt ' % }
4937{% endhighlight %}
5038
5139### Result
@@ -61,39 +49,28 @@ This C# example uses the LINQ Aggregate method with a dynamic expression to crea
6149
6250### LINQ
6351{% highlight csharp %}
64- private void uiAggregate_Seed_LINQ_Click(object sender, EventArgs e)
65- {
66- var startBalance = 100.0;
52+ var startBalance = 100.0;
6753
68- int[] attemptedWithdrawals = {20, 10, 40, 50, 10, 70, 30};
54+ int[ ] attemptedWithdrawals = {20, 10, 40, 50, 10, 70, 30};
6955
70- var endBalance = attemptedWithdrawals.Aggregate(startBalance, (balance, nextWithdrawal) => nextWithdrawal <= balance ? balance - nextWithdrawal : balance);
56+ var endBalance = attemptedWithdrawals.Aggregate(startBalance, (balance, nextWithdrawal) => nextWithdrawal <= balance ? balance - nextWithdrawal : balance);
7157
72- var sb = new StringBuilder();
73-
74- sb.AppendLine("Ending balance: {0}", endBalance);
75-
76- My.Result.Show(My.LinqResultType.Linq, uiResult, sb);
77- }
58+ Console.WriteLine("Ending balance: {0}", endBalance);
7859{% endhighlight %}
60+ {% include component-try-it.html href='https://dotnetfiddle.net/LqobT0 ' %}
7961
8062### LINQ Execute
8163{% highlight csharp %}
82- private void uiAggregate_Seed_LINQ_Execute_Click(object sender, EventArgs e)
83- {
84- var startBalance = 100.0;
85-
86- int[] attemptedWithdrawals = {20, 10, 40, 50, 10, 70, 30};
64+ var startBalance = 100.0;
8765
88- var endBalance = attemptedWithdrawals.Execute<double>("Aggregate(startBalance, (balance, nextWithdrawal) => ((nextWithdrawal <= balance) ? (balance - nextWithdrawal) : balance)", new {startBalance}) ;
66+ int [ ] attemptedWithdrawals = {20, 10, 40, 50, 10, 70, 30} ;
8967
90- var sb = new StringBuilder( );
68+ var endBalance = attemptedWithdrawals.Execute< double >("Aggregate(startBalance, (balance, nextWithdrawal) => ((nextWithdrawal <= balance) ? (balance - nextWithdrawal) : balance)", new {startBalance} );
9169
92- sb.AppendLine ("Ending balance: {0}", endBalance);
70+ Console.WriteLine ("Ending balance: {0}", endBalance);
9371
94- My.Result.Show(My.LinqResultType.LinqExecute, uiResult, sb);
95- }
9672{% endhighlight %}
73+ {% include component-try-it.html href='https://dotnetfiddle.net/p67L8v ' %}
9774
9875### Result
9976{% highlight text %}
0 commit comments