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
using System;

public class Default
{
    public static void Main(string[] args)
    {
        Func<int, string>[] selectors = {
            x => x % 3 == 0 && x % 5 == 0 ? "FizzBuzz" : null,
            x => x % 3 == 0 ? "Fizz" : null,
            x => x % 5 == 0 ? "Buzz" : null,
            x => x.ToString()
        };

        string result;
        for(int i = 1; i <= 100; i++)
        {
            foreach(Func<int, string> f in selectors)
            {
                result = f(i);
                if(result != null)
                {
                    Console.WriteLine(result);
                    break;
                }
            }
        }
    }
}

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
72
73
74
75
76
77
78
79
80
//  Microsoft (R) .NET Framework IL Disassembler.  Version 4.0.30319.1
//  Copyright (c) Microsoft Corporation.  All rights reserved.



// Metadata version: v4.0.30319
.assembly extern mscorlib
{
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
  .ver 4:0:0:0
}
.assembly Gobiner.CSharpPad.Eval.Evil2117998486
{
  .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) 
  .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
                                                                                                             63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 )       // ceptionThrows.
  .hash algorithm 0x00008004
  .ver 0:0:0:0
}
.module Gobiner.CSharpPad.Eval.Evil2117998486.exe
// MVID: {DB7DEAAB-3CDD-4A83-BF5A-5F9AA093AFB4}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003       // WINDOWS_CUI
.corflags 0x00000001    //  ILONLY
// Image base: 0x0000000000C60000


// =============== CLASS MEMBERS DECLARATION ===================

.class public auto ansi beforefieldinit Default
       extends [mscorlib]System.Object
{
  .field private static class [mscorlib]System.Func`2<int32,string> 'CS$<>9__CachedAnonymousMethodDelegate4'
  .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 
  .field private static class [mscorlib]System.Func`2<int32,string> 'CS$<>9__CachedAnonymousMethodDelegate5'
  .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 
  .field private static class [mscorlib]System.Func`2<int32,string> 'CS$<>9__CachedAnonymousMethodDelegate6'
  .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 
  .field private static class [mscorlib]System.Func`2<int32,string> 'CS$<>9__CachedAnonymousMethodDelegate7'
  .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 
  .method public hidebysig static void  Main(string[] args) cil managed
  {
    .entrypoint
    // 
    .maxstack  5
    .locals init (class [mscorlib]System.Func`2<int32,string>[] V_0,
             string V_1,
             int32 V_2,
             class [mscorlib]System.Func`2<int32,string> V_3,
             class [mscorlib]System.Func`2<int32,string>[] V_4,
             class [mscorlib]System.Func`2<int32,string>[] V_5,
             int32 V_6)
    IL_0000:  ldc.i4.4
    IL_0001:  newarr     class [mscorlib]System.Func`2<int32,string>
    IL_0006:  stloc.s    V_4
    IL_0008:  ldloc.s    V_4
    IL_000a:  ldc.i4.0
    IL_000b:  ldsfld     class [mscorlib]System.Func`2<int32,string> Default::'CS$<>9__CachedAnonymousMethodDelegate4'
    IL_0010:  brtrue.s   IL_0023

    IL_0012:  ldnull
    IL_0013:  ldftn      string Default::'<Main>b__0'(int32)
    IL_0019:  newobj     instance void class [mscorlib]System.Func`2<int32,string>::.ctor(object,
                                                                                          native int)
    IL_001e:  stsfld     class [mscorlib]System.Func`2<int32,string> Default::'CS$<>9__CachedAnonymousMethodDelegate4'
    IL_0023:  ldsfld     class [mscorlib]System.Func`2<int32,string> Default::'CS$<>9__CachedAnonymousMethodDelegate4'
    IL_0028:  stelem.ref
    IL_0029:  ldloc.s    V_4
    IL_002b:  ldc.i4.1
    IL_002c:  ldsfld     class [mscorlib]System.Func`2<int32,string> Default::'CS$<>9__CachedAnonymousMethodDelegate5'
    IL_0031:  brtrue.s   IL_0044

    IL_0033:  ldnull
    IL_0034:  ldftn      string Default::'<Main>b__1'(int32)
    IL_003a:  newobj     instance void class [mscorlib]System.Func`2<int32,string>::.ctor(object,
                                                                                          native int)
    IL_003f:  stsfld     class [mscorli
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
Fizz
37
38
Fizz
Buzz
41
Fizz
43
44
FizzBuzz
46
47
Fizz
49
Buzz
Fizz
52
53
Fizz
Buzz
56
Fizz
58
59
FizzBuzz
61
62
Fizz
64
Buzz
Fizz
67
68
Fizz
Buzz
71
Fizz
73
74
FizzBuzz
76
77
Fizz
79
Buzz
Fizz
82
83
Fizz
Buzz
86
Fizz
88
89
FizzBuzz
91
92
Fizz
94
Buzz
Fizz
97
98
Fizz
Buzz