InterfaceTransofmer - mehdimo/janett GitHub Wiki

Interfaces in java and C# have some differences, both in definition and usage.

Interface fields

In java we can define an interface containing fields, but in C# we can't do this.

[Java]

public interface ITest
{
    public static int Default;
    public static String Name;
}

For translating such a code to .Net we must define a new class outside the interface and move interface fields there.

[C#]

public interface ITest
{
}
public class ITest_Fields
{
    public static int Default;
    public static String Name;
}

Interface inner class

In Java, we can define inner class in interfaces. We should bring out inner class from enclosing interface in C#.

[Java]

public interface ITest
{
    public class InnerTest
    {
    }
}

[C#]

public interface ITest
{
}
public class InnerTest
{
}