forked from ProfessionalCSharp/ProfessionalCSharp7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
31 lines (26 loc) · 754 Bytes
/
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
using System;
using static System.Console;
using static UsingStatic.FunctionalExtensions;
namespace UsingStatic
{
class Program
{
static void Main()
{
new Resource().Use(r => r.Foo());
using (var r = new Resource())
{
r.Foo();
}
Func<int, int> f1 = x => x + 1;
Func<int, int> f2 = x => x + 2;
Func<int, int> f3 = Compose(f1, f2);
var x1 = f3(39);
WriteLine(x1);
var greetPerson = Compose(
new Func<string, Person>(name => new Person(name)),
person => $"Hello, {person.FirstName}");
WriteLine(greetPerson("Mario Andretti"));
}
}
}