7

I have some useful code written in C# and I want to use it in my android app. Can I use it directly, or it is nesessary to rewrite it on Java?

6 Answers 6

9

You will need to rewrite it. Or Run your C# code as a web service (WCF or Web API) and have your java application talk to the web service

Sign up to request clarification or add additional context in comments.

Comments

5

There's a project called Mono for Android, and it gives you the ability to write android apps in C#:

http://xamarin.com/monoforandroid

3 Comments

As I understand it is possible to write the whole project using c# and mono, but I can't find is it possible to use just a bunch of C# code in a java app.
@user1735198 if that's the case, you can go with twaldron's answer.
@user1735198 - If it wasn't possible to use C# within a Java application then Mono for Android wouldn't be possible.
4

If you are looking to do it for free, you probably have to just rewrite it in Java.

Comments

1

You are looking for Mono for Android~

enter image description here

Comments

1

If you are looking to mix C# and Java, then it will probably be more trouble than it is worth. However using Mono for Android and reading this similar question you can find the Droid you are looking for.

Comments

1

Depending on how many lines of code you are talking about, I would start with one of the size limited demo versions of the several 'csharp to java' code converters available. Google 'csharp to java'. You won't necessarily get perfect, runnable, java code but it will break the back of the conversion exercise for you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.