Updated with review feedback.
[mono.git] / mcs / tests / test-anon-155.cs
1 using System;
2
3 public sealed class Thing<TFirst> where TFirst : class
4 {
5         public static Thing<TFirst> Create<TSecond> (Func<TFirst, TSecond> fn)
6                 where TSecond : class
7         {
8                 return new Thing<TFirst> (
9                         delegate (TFirst item) {
10                                 TSecond foo = item == null ? null : fn (item);
11                                 Console.WriteLine (foo);
12                         });
13         }
14
15         public void SomeAction ()
16         {
17                 _fn (null);
18         }
19
20         private Thing (Action<TFirst> fn)
21         {
22                 _fn = fn;
23         }
24
25         Action<TFirst> _fn;
26 }
27
28 public static class Program
29 {
30         public static void Main ()
31         {
32                 var foo = Thing<object>.Create (x => x);
33                 foo.SomeAction ();
34         }
35 }