-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathProgram.cs
71 lines (57 loc) · 2.38 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using System.Linq;
using System.ComponentModel;
using linqshared;
namespace linq_miscellaneous
{
class Program : ProgramBase
{
static void Main(string[] args)
{
Linq94();
// Linq95();
// Linq96();
// Linq97();
}
[Category("Miscellaneous Operators")]
[Description("This sample creates a contatenation of each array's values, one after the other.")]
static void Linq94()
{
int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 };
int[] numbersB = { 1, 3, 5, 7, 8 };
var allNumbers = numbersA.Concat(numbersB);
Console.WriteLine("All numbers from both arrays:");
allNumbers.ForEach(Console.WriteLine);
}
[ Category("Miscellaneous Operators")]
[Description("This sample creates a contatenation that contains the names of all customers and products, including any duplicates.")]
static void Linq95()
{
var customers = GetCustomerList();
var products = GetProductList();
var customerNames = customers.Select(cust => cust.CompanyName);
var productNames = products.Select(prod => prod.ProductName);
var allNames = customerNames.Concat(productNames);
Console.WriteLine("Customer and product names:");
allNames.ForEach(Console.WriteLine);
}
[Category("Miscellaneous Operators")]
[Description("This sample checks if two sequences match on all elements in the same order.")]
static void Linq96()
{
var wordsA = new[] { "cherry", "apple", "blueberry" };
var wordsB = new[] { "cherry", "apple", "blueberry" };
var match = wordsA.SequenceEqual(wordsB);
Console.WriteLine($"The sequences match: {match}");
}
[Category("Miscellaneous Operators")]
[Description("This sample checks if two sequences match on all elements in the same order.")]
static void Linq97()
{
var wordsA = new[] { "cherry", "apple", "blueberry" };
var wordsB = new[] { "apple", "blueberry", "cherry" };
var match = wordsA.SequenceEqual(wordsB);
Console.WriteLine($"The sequences match: {match}");
}
}
}