- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
To Continue Learning Please Login
Login with Google