开发者

is there any convert reference between java (for android) and C#?

开发者 https://www.devze.com 2023-03-04 02:33 出处:网络
is there any convert reference between开发者_运维问答 java (for android) and C# ? for example:

is there any convert reference between开发者_运维问答 java (for android) and C# ?

for example:

in C#: messagebox.show(sum.tostring()); ==> in java ???


There's no way to convert C# code to Java, but they're really similar. If you have a strong handle on C#, I find it very easy to ramp up with Java for Android. In your example, there are two things going on, so look at them individually.

Converting between value types and strings is very similar. Just as in C#, all the primitive types have corresponding wrapper classes (int has Integer, etc). These all have a parseXXX method and a toString method, and the String class has overloads of the valueOf method for all of the primitive types.

for example:

int someInt = Integer.parseInt(someString);
String someString = someInt.toString();
String someString = String.valueOf(someInt);

As far as showing a dialog in one line of code, that doesn't exist in Android (assuming you're talking about Android specifically because of the tag).

If you just want to see information, you can use Toast. If you need to actually display a dialog that the user interacts with, you need to learn how to display dialogs in Android.

http://developer.android.com/guide/topics/ui/dialogs.html

http://developer.android.com/guide/topics/ui/notifiers/toasts.html

http://developer.android.com/reference/java/lang/String.html

http://developer.android.com/reference/java/lang/package-summary.html


We have developed the CS2J tool for converting C# programs to Java. Unlike other converters it doesn't just translate the C# syntax into Java syntax it also has a flexible translation library so that you can convert Net framework and 3rd party library calls into their Java equivalent.

It doesn't have any specific support for the mobile SDKs (though that would be a good idea), but the translations are extensible so you can easily add a translation for the "messagebox" class and a translation its "show" method and so on.

Although C# and Java are similar languages there are a lot of details that are different and we think such a tool is very useful if you want to convert decent sized projects.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号