Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
C# Equivalent to Java Functional Interfaces
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() {
}
} Advertisements
