C# 4.0 Compiler Crash

后端 未结 4 2062
不知归路
不知归路 2021-02-04 23:52

This code sample is not able to be compiled. Any work arounds out there?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

n         


        
4条回答
  •  不要未来只要你来
    2021-02-05 00:11

    Here's another workaround: don't use Func, use a good old delegate type.

    public delegate dynamic Church(dynamic x, dynamic y);
    
    class Program {
        static void Main(string[] args) {
            Church True = (a, b) => a;
            Church False = (a, b) => b;
    
            Func And = (x, y) => x(y(True, False), False);
        }
    }
    

    This also has the benefit, that Church is defined everywhere, and not just as a per-file using alias.

提交回复
热议问题