-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKod24_Join.cs
More file actions
35 lines (31 loc) · 838 Bytes
/
Kod24_Join.cs
File metadata and controls
35 lines (31 loc) · 838 Bytes
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
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp2
{
class Program
{
static void Main()
{
var students = new List<(string Name, int GroupID)>
{
("Anna", 1),
("Bob", 2),
("Charlie", 1)
};
var groups = new List<(int GroupID, string Name)>
{
(1, "A"),
(2, "B")
};
var joinedList = students.Join(groups,
s => s.GroupID,
g => g.GroupID,
(s, g) => new { StudentName = s.Name, GroupName = g.Name });
foreach (var item in joinedList)
{
Console.WriteLine($"{item.StudentName}: {item.GroupName}");
}
}
}
}