repl.it
@kironroy/

actionfuncs

C#

No description

fork
loading
Files
  • main.cs
  • main.exe
main.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FunctionalProgramming
{
    class Program
    {
          
        static void Main(string[] args)
        {
            Action<string> sayGreeting;

            Func<string, string> conversate = delegate (string message)
            {
                Console.WriteLine(message);
                return Console.ReadLine();
            };

            string userInput = conversate("What's your name ");

            sayGreeting = delegate(string greeting)
            {
                Console.WriteLine(string.Format(greeting, userInput));
            };
            
            sayGreeting("Hello, {0}");
            conversate("Nice to see you!");
            conversate("Are you doing well?");
            sayGreeting("Later, {0}");
        }
    }
}