 |
CodePorting C#2Java Application is a cloud based converter that has accomplished immense popularity because of its broad collection of supported C# language constructs. Its powerful engine parse and transforms thousand of C# souce code lines to java in few seconds.
CodePorting has recently imrpoved its C#2Java engine and now its capable of converting C# source code having delegates in it to java. In C# programming language, delegate is a form of type-safe function pointer which is mostly used for call backs and event listener. Unfortunately, there is no delegate construct in Java so while converting C# code to Java, C#2Java engine intelligently converts the delegates to interfaces with the invoke method call by auto generating required code.
Lets take an example of how codeporting engine converts C# delegates to java interfaces.
C# Code:
using System.Collections.Generic;
using System;
using System.Linq;
public class Delegate
{
public static void Main(string[> arg)
{
Del handler = DelegateMethod;
// Call the delegate.
handler("Hello World");
}
public delegate void Del(string message);
public static void DelegateMethod(string message)
{
Console.WriteLine(message);
}
}
Java Code:
// ********* THIS FILE IS AUTO PORTED FROM C# USING CODEPORTING.COM *********
public class Delegate
{
public static void main(String[> arg)
{
Del handler = new Del() {
public void invoke(String message) {
delegateMethod(message);
}};
// Call the delegate.
handler.invoke("Hello World");
}
public interface Del{
void invoke(String message);
}
public static void delegateMethod(String message)
{
System.out.printf(message);
}
}
Newly added articles and documentation pages
- CodePorting Converts C# Delegates to Java Instantly[/url
- CodePorting has converted more than 5 Million lines of C# code to Java
- Convert C# is Operator to instanceof Operator in Java
- List of Conversions Supported by CodePorting C#2Java Engine
About CodePorting C#2Java App
CodePorting helps you make your .NET applications cross platform compatible and allows migrating your .NET solutions, projects and files into Java in the cloud. Other than speed and accuracy of conversion; port your C# code directly either by uploading .cs files contained in a .zip file or import directly from popular version control repositories like GIT, Mercurial HG and SubVersion. You can also download a Microsoft Visual Studio plugin and convert C# code in the real time without leaving the development environment. You may also build your own customized code conversion applications using CodePorting APIs.
Read more about CodePorting
- Start converting C# Apps and source code to Java
- CodePorting Homepage
- CodePorting C#2Java Homepage
- CodePorting Documentation
- Watch out CodePorting introductory video
Contact Us
Suite 163, 79 Longueville Road
Lane Cove, NSW 2066, Australia
Codeporting – Your CodePorting Experts
Skype Name: CodePorting
Email: support [@] codeporting [dot] com
|
|
|
|