Equivalent of Java’s Functional Interfaces in C# is Delegates.
Let us see the implementation of functional interface in Java −
Example
@FunctionalInterface
public interface MyInterface {
void invoke();
}
public class Demo {
void method(){
MyInterface x = () -> MyFunc ();
x.invoke();
}
void MyFunc() {
}
}The same implementation in C# delagates −
Example
public delegate void MyInterface ();
public class Demo {
internal virtual void method() {
MyInterface x = () => MyFunc ();
x();
}
internal virtual void MyFunc() {
}
}