C# 相当于 Java 函数式接口

C# 相当于 Java 函数式接口

@FunctionalInterface
public interface MyInterface {
void invoke();
}
public class Demo {
void method(){
MyInterface x = () -> MyFunc ();
x.invoke();
}
void MyFunc() {
}
}

C# 延迟中的相同实现 -

示例

public delegate void MyInterface ();
public class Demo {
internal virtual void method() {
MyInterface x = () => MyFunc ();
x();
}
internal virtual void MyFunc() {
}
}

登录后复制

以上就是C# 相当于 Java 函数式接口的详细内容,更多请关注每日运维网(www.mryunwei.com)其它相关文章!