zarfishan zahid

zarfishan zahid

  • NA
  • 0
  • 18.4k

Convert C# Proprties to Java Online using CodePortingC#2Java App

May 23 2012 12:17 AM

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:

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

 

 

Java code generated by CodePorting:

 

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


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