Skip to content

Commit afe4ac5

Browse files
authored
Merge pull request #804 from dotnet/master
Update live with current master
2 parents 6e0c93e + db8e616 commit afe4ac5

File tree

4 files changed

+59
-81
lines changed

4 files changed

+59
-81
lines changed

snippets/csharp/VS_Snippets_CLR_System/system.collections.generic.list.sort/cs/Sort1.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class Example
66
{
77
public static void Main()
88
{
9-
String[] names = { "Samuel", "Dakota", "Koani", "Saya", "Vanya",
9+
String[] names = { "Samuel", "Dakota", "Koani", "Saya", "Vanya", "Jody",
1010
"Yiska", "Yuma", "Jody", "Nikita" };
1111
var nameList = new List<String>();
1212
nameList.AddRange(names);
@@ -26,9 +26,9 @@ public static void Main()
2626
}
2727
// The example displays the following output:
2828
// List in unsorted order:
29-
// Samuel Dakota Koani Saya Vanya Yiska Yuma Jody Nikita
29+
// Samuel Dakota Koani Saya Vanya Jody Yiska Yuma Jody Nikita
3030
//
3131
// List in sorted order:
32-
// Dakota Jody Koani Nikita Samuel Saya Vanya Yiska Yuma
32+
// Dakota Jody Jody Koani Nikita Samuel Saya Vanya Yiska Yuma
3333
// </Snippet2>
3434

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// <Snippet1>
2+
using System;
3+
using System.Collections;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
7+
class Example
8+
{
9+
static void Main(string[] args)
10+
{
11+
int[] values = { 2, 4, 6, 8, 10 };
12+
ShowCollectionInformation(values);
13+
14+
var names = new List<string>();
15+
names.AddRange( new string[] { "Adam", "Abigail", "Bertrand", "Bridgette" } );
16+
ShowCollectionInformation(names);
17+
18+
List<int> numbers = null;
19+
ShowCollectionInformation(numbers);
20+
}
21+
22+
private static void ShowCollectionInformation<T>(T coll)
23+
{
24+
switch (coll)
25+
{
26+
case Array arr:
27+
Console.WriteLine($"An array with {arr.Length} elements.");
28+
break;
29+
case IEnumerable<int> ieInt:
30+
Console.WriteLine($"Average: {ieInt.Average(s => s)}");
31+
break;
32+
case IList list:
33+
Console.WriteLine($"{list.Count} items");
34+
break;
35+
case IEnumerable ie:
36+
string result = "";
37+
foreach (var e in ie)
38+
result += "${e} ";
39+
Console.WriteLine(result);
40+
break;
41+
case object o:
42+
Console.WriteLine($"A instance of type {o.GetType().Name}");
43+
break;
44+
default:
45+
Console.WriteLine("Null passed to this method.");
46+
break;
47+
}
48+
}
49+
}
50+
// The example displays the following output:
51+
// An array with 5 elements.
52+
// 4 items
53+
// Null passed to this method.
54+
// </Snippet1>
55+
56+

snippets/csharp/language-reference/operators/ConditionalLogicalOperatorsExamples.cs

Lines changed: 0 additions & 57 deletions
This file was deleted.

snippets/csharp/language-reference/operators/LogicalNegationExamples.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)