函数式接口详细定义 package java.lang; import java.lang.annotation.*; /** * An informative annotation type used to indicate that an interface * type declaration is intended to be a <i>functional interface</i> as * defined by the Java Language Specificat
delegate bool D(); delegate bool D2(int i); class Test { D del; D2 del2; public void TestMethod(int input) { ; // Initialize the delegates with lambda expressions. // Note access to 2 outer variables. // del will be invoked within this method. del =
在编码时,由于开始是在winform下进行简单的测试开发的,后来代码多了,就想分到不同的类里边去,可是因为原来的测试是在同一个form下的,所以对于函数调用可以很方便,而一旦跨类之后,就会发现,这函数的耦合度太高,以至于不知道该怎么样解耦到类里边去.这时,不妨使用委托类型的Func和Action来实现. 下面是最开始测试时在winform里写的简单代码 using System; using System.Collections.Generic; using System.ComponentMo