Skip to content

Commit 518f847

Browse files
committed
Work in progress of re-formatting
1 parent a7bcfe1 commit 518f847

File tree

15 files changed

+168
-146
lines changed

15 files changed

+168
-146
lines changed

src/csharp/linq-aggregate/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static void Main(string[] args)
3333
}
3434

3535
[Category("Aggregate Operators")]
36-
[Description("This sample uses Count to get the number of unique prime factors of 300.")]
36+
[Description("This sample gets the number of unique prime factors of 300.")]
3737
static void Linq73()
3838
{
3939
var primeFactorsOf300 = new [] { 2, 2, 3, 5, 5 };
@@ -44,7 +44,7 @@ static void Linq73()
4444
}
4545

4646
[Category("Aggregate Operators")]
47-
[Description("This sample uses Count to get the number of odd ints in the array.")]
47+
[Description("This sample gets the number of odd ints in the array.")]
4848
static void Linq74()
4949
{
5050
var numbers = new [] { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };

src/csharp/linq-conversion/Program.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.ComponentModel;
34
using System.Linq;
45
using linqshared;
@@ -16,15 +17,15 @@ static void Main(string[] args)
1617
}
1718

1819
[Category("Conversion Operators")]
19-
[Description("This sample uses ToArray to immediately evaluate a sequence into an array.")]
20+
[Description("This sample converts a list to an array.")]
2021
static void Linq54()
2122
{
22-
double[] doubles = { 1.7, 2.3, 1.9, 4.1, 2.9 };
23+
var list = new List<double> { 1.7, 2.3, 1.9, 4.1, 2.9 };
2324

24-
var sortedDoubles = doubles.OrderByDescending(d => d);
25+
var doublesArray = list
26+
.OrderByDescending(d => d)
27+
.ToArray();
2528

26-
var doublesArray = sortedDoubles.ToArray();
27-
2829
Console.WriteLine("Every other double from highest to lowest:");
2930
for (var d = 0; d < doublesArray.Length; d += 2)
3031
{
@@ -34,21 +35,21 @@ static void Linq54()
3435

3536

3637
[Category("Conversion Operators")]
37-
[Description("This sample uses ToList to immediately evaluate a sequence into a List<T>.")]
38+
[Description("This sample converts an array to a list")]
3839
static void Linq55()
3940
{
40-
string[] words = { "cherry", "apple", "blueberry" };
41-
42-
var sortedWords = words.OrderBy(x => x);
41+
var words = new[] { "cherry", "apple", "blueberry" };
4342

44-
var wordList = sortedWords.ToList();
43+
var wordList = words
44+
.OrderBy(x => x)
45+
.ToList();
4546

4647
Console.WriteLine("The sorted word list:");
4748
wordList.ForEach(Console.WriteLine);
4849
}
4950

5051
[Category("Conversion Operators")]
51-
[Description("This sample uses ToDictionary to immediately evaluate a sequence and a related key expression into a dictionary.")]
52+
[Description("This sample converts an array of records to a dictionary")]
5253
static void Linq56()
5354
{
5455
var scoreRecords =
@@ -65,10 +66,10 @@ static void Linq56()
6566
}
6667

6768
[Category("Conversion Operators")]
68-
[Description("This sample uses OfType to return only the elements of the array that are of type double.")]
69+
[Description("This sample filters all elements that matches the type double.")]
6970
static void Linq57()
7071
{
71-
object[] numbers = { null, 1.0, "two", 3, "four", 5, "six", 7.0 };
72+
var numbers = new object[]{ null, 1.0, "two", 3, "four", 5, "six", 7.0 };
7273

7374
var doubles = numbers.OfType<double>();
7475

src/csharp/linq-element/Program.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ class Program : ProgramBase
99
{
1010
static void Main(string[] args)
1111
{
12-
//Linq58();
13-
// Linq59();
14-
// Linq61();
15-
// Linq62();
16-
// Linq64();
12+
Linq58();
13+
// Linq59();
14+
// Linq61();
15+
// Linq62();
16+
// Linq64();
1717
}
1818

1919
[Category("Element Operators")]
20-
[Description("This sample uses First to return the first matching element as a Product, instead of as a sequence containing a Product.")]
20+
[Description("This sample returns the first matching element as a Product, instead of as a sequence containing a Product.")]
2121
static void Linq58()
2222
{
2323
var products = GetProductList();
@@ -28,7 +28,7 @@ static void Linq58()
2828
}
2929

3030
[Category("Element Operators")]
31-
[Description("This sample uses First to find the first element in the array that starts with 'o'.")]
31+
[Description("This sample finds the first element in the array that starts with 'o'.")]
3232
static void Linq59()
3333
{
3434
var strings = new []{ "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
@@ -40,7 +40,7 @@ static void Linq59()
4040

4141

4242
[Category("Element Operators")]
43-
[Description("This sample uses FirstOrDefault to try to return the first element of the sequence unless there are no elements, in which case the default value for that type is returned. FirstOrDefault is useful for creating outer joins.")]
43+
[Description("This sample returns the first or default if nothing is found, to try to return the first element of the sequence unless there are no elements, in which case the default value for that type is returned.")]
4444
static void Linq61()
4545
{
4646
var numbers = new int[0];
@@ -51,7 +51,7 @@ static void Linq61()
5151
}
5252

5353
[Category("Element Operators")]
54-
[Description("This sample uses FirstOrDefault to return the first product whose ProductID is 789 as a single Product object, unless there is no match, in which case null is returned.")]
54+
[Description("This sample returns the first or default if nothing is found, to return the first product whose ProductID is 789 as a single Product object, unless there is no match, in which case null is returned.")]
5555
static void Linq62()
5656
{
5757
var products = GetProductList();
@@ -62,7 +62,7 @@ static void Linq62()
6262
}
6363

6464
[Category("Element Operators")]
65-
[Description("This sample uses ElementAt to retrieve the second number greater than 5 from an array.")]
65+
[Description("This sample retrieve the second number greater than 5 from an array.")]
6666
static void Linq64()
6767
{
6868
var numbers = new [] { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };

src/csharp/linq-generation/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static void Main(string[] args)
1414
}
1515

1616
[Category("Generation Operators")]
17-
[Description("This sample uses Range to generate a sequence of numbers from 100 to 149 that is used to find which numbers in that range are odd and even.")]
17+
[Description("This sample uses generates a sequence of numbers from 100 to 149 that is used to find which numbers in that range are odd and even.")]
1818
static void Linq65()
1919
{
2020
var numbers = Enumerable.Range(100, 50)
@@ -29,7 +29,7 @@ static void Linq65()
2929
}
3030

3131
[Category("Generation Operators")]
32-
[Description("This sample uses Repeat to generate a sequence that contains the number 7 ten times.")]
32+
[Description("This sample uses generates a sequence of repeated numbers that contains the number 7 ten times.")]
3333
static void Linq66()
3434
{
3535
var numbers = Enumerable.Repeat(7, 10);

src/csharp/linq-grouping/Program.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ private string GetCanonicalString(string word)
3939
}
4040

4141
[Category("Grouping Operators")]
42-
[Description("This sample uses group by to partition a list of numbers by their remainder when divided by 5.")]
43-
private static void Linq40()
42+
[Description("This sample uses grouping to partition a list of numbers by their remainder when divided by 5.")]
43+
static void Linq40()
4444
{
4545
var numbers = new[] { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
4646

@@ -61,8 +61,8 @@ private static void Linq40()
6161
}
6262

6363
[Category("Grouping Operators")]
64-
[Description("This sample uses group by to partition a list of words by their first letter.")]
65-
private static void Linq41()
64+
[Description("This sample uses grouping to partition a list of words by their first letter.")]
65+
static void Linq41()
6666
{
6767
var words = new [] { "blueberry", "chimpanzee", "abacus", "banana", "apple", "cheese" };
6868

@@ -83,8 +83,8 @@ private static void Linq41()
8383
}
8484

8585
[Category("Grouping Operators")]
86-
[Description("This sample uses group by to partition a list of products by category.")]
87-
private static void Linq42()
86+
[Description("This sample uses grouping to partition a list of products by category.")]
87+
static void Linq42()
8888
{
8989
var products = GetProductList();
9090

@@ -101,8 +101,8 @@ private static void Linq42()
101101
}
102102

103103
[Category("Grouping Operators")]
104-
[Description("This sample uses group by to partition a list of each customer's orders, first by year, and then by month.")]
105-
private static void Linq43()
104+
[Description("This sample uses nested grouping to partition a list of each customer's orders, first by year, and then by month.")]
105+
static void Linq43()
106106
{
107107
var customers = GetCustomerList();
108108

@@ -136,7 +136,7 @@ private static void Linq43()
136136

137137
[Category("Grouping Operators")]
138138
[Description("This sample uses GroupBy to partition trimmed elements of an array using a custom comparer that matches words that are anagrams of each other.")]
139-
private static void Linq44()
139+
static void Linq44()
140140
{
141141
var anagrams = new [] { "from ", " salt", " earn ", " last ", " near ", " form " };
142142
var orderGroups = anagrams
@@ -147,7 +147,7 @@ private static void Linq44()
147147

148148
[Category("Grouping Operators")]
149149
[Description("This sample uses GroupBy to partition trimmed elements of an array using a custom comparer that matches words that are anagrams of each other, and then converts the results to uppercase.")]
150-
private static void Linq45()
150+
static void Linq45()
151151
{
152152
var anagrams = new [] { "from ", " salt", " earn ", " last ", " near ", " form " };
153153

src/csharp/linq-ordering/Program.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static void Main(string[] args)
2525

2626

2727
[Category("Ordering Operators")]
28-
[Description("This sample uses orderby to sort a list of words alphabetically.")]
28+
[Description("This sample uses ordering to sort a list of words alphabetically.")]
2929
static void Linq28()
3030
{
3131
var words = new [] { "cherry", "apple", "blueberry" };
@@ -37,7 +37,7 @@ static void Linq28()
3737
}
3838

3939
[Category("Ordering Operators")]
40-
[Description("This sample uses orderby to sort a list of words by length.")]
40+
[Description("This sample uses ordering to sort a list of words by length.")]
4141
static void Linq29()
4242
{
4343
var words = new [] { "cherry", "apple", "blueberry" };
@@ -49,7 +49,7 @@ static void Linq29()
4949
}
5050

5151
[Category("Ordering Operators")]
52-
[Description("This sample uses orderby to sort a list of products by name. Use the \"descending\" keyword at the end of the clause to perform a reverse ordering.")]
52+
[Description("This sample uses ordering to sort a list of products by name.")]
5353
static void Linq30()
5454
{
5555
var products = GetProductList();
@@ -60,7 +60,7 @@ static void Linq30()
6060
}
6161

6262
[Category("Ordering Operators")]
63-
[Description("This sample uses an OrderBy clause with a custom comparer to do a case-insensitive sort of the words in an array.")]
63+
[Description("This sample uses case-insensitive ordering to sort the words in an array.")]
6464
static void Linq31()
6565
{
6666
var words = new [] { "aPPLE", "AbAcUs", "bRaNcH", "BlUeBeRrY", "ClOvEr", "cHeRry" };
@@ -71,7 +71,7 @@ static void Linq31()
7171
}
7272

7373
[Category("Ordering Operators")]
74-
[Description("This sample uses OrderBy and descending to sort a list of doubles from highest to lowest.")]
74+
[Description("This sample uses reverse ordering to sort a list of doubles from highest to lowest.")]
7575
static void Linq32()
7676
{
7777
var doubles = new[]{ 1.7, 2.3, 1.9, 4.1, 2.9 };
@@ -83,7 +83,7 @@ static void Linq32()
8383
}
8484

8585
[Category("Ordering Operators")]
86-
[Description("This sample uses OrderBy to sort a list of products by units in stock from highest to lowest.")]
86+
[Description("This sample uses reverse ordering to sort a list of products by units in stock from highest to lowest.")]
8787
static void Linq33()
8888
{
8989
var products = GetProductList();
@@ -94,7 +94,7 @@ static void Linq33()
9494
}
9595

9696
[Category("Ordering Operators")]
97-
[Description("This sample uses OrderByDescending with a custom comparer.")]
97+
[Description("This sample uses reverse case-insensitive ordering to sort the words in an array.")]
9898
static void Linq34()
9999
{
100100
var words = new [] { "aPPLE", "AbAcUs", "bRaNcH", "BlUeBeRrY", "ClOvEr", "cHeRry" };
@@ -105,7 +105,7 @@ static void Linq34()
105105
}
106106

107107
[Category("Ordering Operators")]
108-
[Description("This sample uses aOrderByto sort a list of digits, first by length of their name, and then alphabetically by the name itself.")]
108+
[Description("This sample uses nested ordering, first by length of their name, and then alphabetically by the name itself.")]
109109
static void Linq35()
110110
{
111111
var digits = new [] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
@@ -119,7 +119,7 @@ static void Linq35()
119119
}
120120

121121
[Category("Ordering Operators")]
122-
[Description("The first query in this sample uses OrderBy and ThenBy with a custom comparer to sort first by word length and then by a case-insensitive sort of the words in an array.")]
122+
[Description("This sample uses case-insensitive nested ordering, with a custom comparer to sort first by word length and then by a case-insensitive sort of the words in an array.")]
123123
static void Linq36()
124124
{
125125
var words = new [] { "aPPLE", "AbAcUs", "bRaNcH", "BlUeBeRrY", "ClOvEr", "cHeRry" };
@@ -132,7 +132,7 @@ static void Linq36()
132132
}
133133

134134
[Category("Ordering Operators")]
135-
[Description("This sample uses OrderBy and ThenByDescendingo sort a list of products, first by category, and then by unit price, from highest to lowest.")]
135+
[Description("This sample uses nested ordering to sort a list of products, first by category, and then by unit price, from highest to lowest.")]
136136
static void Linq37()
137137
{
138138
var products = GetProductList();
@@ -145,7 +145,7 @@ static void Linq37()
145145
}
146146

147147
[Category("Ordering Operators")]
148-
[Description("This sample uses an OrderBy and a ThenBy clause with a custom comparer to sort first by word length and then by a case-insensitive descending sort of the words in an array.")]
148+
[Description("This sample uses uses case-insensitive reverse nested ordering to sort first by word length and then by a case-insensitive descending sort of the words in an array.")]
149149
static void Linq38()
150150
{
151151
var words = new [] { "aPPLE", "AbAcUs", "bRaNcH", "BlUeBeRrY", "ClOvEr", "cHeRry" };
@@ -158,7 +158,7 @@ static void Linq38()
158158
}
159159

160160
[Category("Ordering Operators")]
161-
[Description("This sample uses Reverse to create a list of all digits in the array whose second letter is 'i' that is reversed from the order in the original array.")]
161+
[Description("This sample uses reverse ordering to create a list of all digits in the array whose second letter is 'i' that is reversed from the order in the original array.")]
162162
static void Linq39()
163163
{
164164
var digits = new [] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };

0 commit comments

Comments
 (0)