CodePorting C#2Java engine allows all C# developers to automatically convert C# constructs to Java code which you do not find in Java by using auto-generated code. There are properties in C# which provide flexible mechanism to read, write or compute the values of private fields. These properties are also called accessors but there are no such C# equivalent properties in Java. While translating code, CodePorting C#2Java engine intelligently generates Java code to provide same functionality as provided by accessors.

Following example shows migration of C# properties in java:

C# Code:

Code
namespace CSharp2java.Tests.Convert.Properties
Code
{
Code
    internal class Test151 : Test15
Code
    {
Code
        internal void Method()
Code
        {
Code
            base.Property = 1;
Code
            int i = base.Property;
Code
            base.Property += 20;
Code
            base.Property++;
Code
            --base.Property;
Code
        }
Code
    }
Code
Code
    public class Test15
Code
    {
Code
        public int Property
Code
        {
Code
            get { return mProperty; }
Code
            set { mProperty = value; }
Code
        }
Code
Code
        private int mProperty;
Code
    }
Code
}

 

 

Java code generated by CodePorting:

 

Code
package CSharp2java.Tests.Convert.Properties;
Code
Code
// ********* THIS FILE IS AUTO PORTED FORM C# USING CODEPORTING.COM *********
Code
Code
class Test151 extends Test15
Code
{
Code
    void method()
Code
    {
Code
        super.setProperty(1);
Code
        int i = super.getProperty();
Code
        super.setProperty(super.getProperty() + 20);
Code
        super.setProperty(super.getProperty() + 1)/*Property++*/;
Code
        super.setProperty(super.getProperty() - 1)/*--Property*/;
Code
    }
Code
}
Code
Code
public class Test15
Code
{
Code
    public int getProperty() { return mProperty; }
Code
    public void setProperty(int value) { mProperty = value; }
Code
Code
    private int mProperty;
Code
}


The Above Java code replicates the functionality of C# Properties through CodePorting C#2Java Engine.

Newly added articles and documentation pages

Overview:   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

Phone:  +61 2 8901 3609     

Email: support [@] codeporting [dot] com