Using CodePorting C#2Java App developers can now migrate C# language constructs even if they don't have a counterpart in java. We have already shown you such example in our previous blogs like converting C# unsigned integer types to java using CodePorting C#2java App. A struct in C# is a user-define type which is declared same as a class, the only difference is that it cannot be inherited from any class and no class can be inherited from it. In this blog we will show you that using CodePorting C#2Java App developers can easily convert C# construct to java in cloud.
See following Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CSharp2Java.Samples.Convert.Structs
{
public class StructsExample
public struct SimpleStruct
public static SimpleStruct DEFAULT = new SimpleStruct();
}
SimpleStruct ss;
private void Method()
SimpleStruct simpleStruct = new SimpleStruct();
Method(simpleStruct);
Method(ss);
Method(this.ss);
Method(SimpleStruct.DEFAULT);
Method(new SimpleStruct());
Method(Get());
private void Method(SimpleStruct s)
private SimpleStruct Get()
return ss;
package CSharp2Java.Samples.Convert.Structs;
// ********* THIS FILE IS AUTO PORTED FORM C# USING CODEPORTING.COM *********
import com.codeporting.csharp2java.System.msObject;
import com.codeporting.csharp2java.java.Struct;
public static /*struct*/ class SimpleStruct extends Struct
public SimpleStruct(){}
private SimpleStruct ss = new SimpleStruct();
private void method()
method(simpleStruct.Clone());
method(ss.Clone());
method(this.ss.Clone());
method(SimpleStruct.DEFAULT.Clone());
method(new SimpleStruct());
method(get().Clone());
private void method(SimpleStruct s)
private SimpleStruct get()
It is clear from the above example that in java a class has been generated by CodePorting C#2Java App for struct defined in C#.
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.
Suite 163, 79 Longueville Road
Lane Cove, NSW 2066, Australia
CodePorting – Your Code Porting Experts
Phone: +61 2 8901 3609
Email: support [@] codeporting [dot] com