Tangible Software Solutions

The Most Trusted Name in Source Code Conversion

C# Equivalent to Java Functional Interfaces

The closest C# equivalent to Java's functional interfaces are C# delegates.

Original Java:

@FunctionalInterface
public interface FooFunctional
{
   void invoke();
}

public class UseFunctionalInterface
{
   void method()
   {
      FooFunctional funcVar = () -> voidMethod();
      funcVar.invoke();
   }
   void voidMethod()
   {
   }
}

Equivalent C#:

public delegate void FooFunctional();

public class UseFunctionalInterface
{
   internal virtual void method()
   {
      FooFunctional funcVar = () => voidMethod();
      funcVar();
   }
   internal virtual void voidMethod()
   {
   }
}

If you need to convert from Java to C# and you are depending on the results being reliable and accurate, then you will want to have Java to C# Converter, the best Java to C# converter, at your fingertips.

Copyright © 1997 - 2017 Tangible Software Solutions Inc.