English 中文(简体)
• 把 Java改为C#:申报接口和创建案例?
原标题:Converting Java to C#: Declaring interface and creating an instance?

我正在将一些java代码C#转换成我的莫诺德roid应用。 我有一些信标,在座标上被宣布,然后先入物体。 我不相信在C#中采用最佳办法。

例如:

public class NumberPicker {

    public interface Formatter {
        String toString(int value);
    }

    public static final NumberPicker.Formatter TWO_DIGIT_FORMATTER =
            new NumberPicker.Formatter() {
             //some code here
            };

}

在c#中这样做的对应或最佳办法是什么?

最佳回答
问题回答

你们必须建立一个能够实施格式接口的班子,然后树立一个榜样。

i.e.

public class MyFormatter : IFormatter
{
     public string ToString(int value)
     {
       //implementation
     }
}

然后与新运营商一起创立了MyFormatter。

public static IFormatter TWO_DIGIT_FORMATTER  = new MyFormatter ();

我对界面的预先定位是在蚊帐世界中做的,但只是公约所需要的。

因此,我发现处理这种情况的最容易的方法是,在你的主要班子内设立一个私人开具的班级,然后从你所需要的许多接口继承。 比如IOnClickListener, IOnMouseDownListener,然后在您的级别上申报,并在需要的地方将其重新使用。 更方便...... 如果您有重复使用或持有相同方法名称的接口,你可以明确宣布这些接口,例如:

IOnClickListener.OnClick(object sender, EventArgs) {

iii

作为一个例子,你显然希望使用真正的方法名称和接口名称。 也不要忘记在你们的网上处理案件。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签