DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Convert between C# and Java with CSharpJavaMerger  (Read 5,921 times)

sindy55

  • Participant
  • Joined in 2009
  • *
  • Posts: 2
Convert between C# and Java with CSharpJavaMerger
« on: September 17, 2009, 06:44 AM »
CSharpJavaMerger is an open source tool. It provides common interfaces of C# and Java and enables you to write one set of code which can be used both by C# and Java.

Below is a method that can be used in both of C# and Java. In the sample, CString is a class defined in the CSharpJavaMerger Framework.

public void AddTwoValues()
{
    try
    {
        CString strValue1 = m_mainForm.GetFirstTextBoxValue();
        CString strValue2 = m_mainForm.GetSecondTextBoxValue();

        int iValue1 = strValue1.ToInteger();
        int iValue2 = strValue2.ToInteger();
        int iResult = iValue1 + iValue2;
        CString strShowResult = CString.ValueOf(iResult);
        m_mainForm.ShowResult(strShowResult);
        CString strSaveResult = new CString(strValue1.GetValue() + " + " + strValue2.GetValue() + " = " + strShowResult.GetValue() + "\n");
        m_mainForm.SaveResult(strSaveResult);
    }
    catch (Exception ee)
    {
        m_mainForm.SaveResult(new CString(ee.Message + "\n"));
        m_mainForm.ShowResult(new CString("Error"));
    }
}

More info on CSharpJavaMerger: http://www.kevingao.net/csharp-java-conversion

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: Convert between C# and Java with CSharpJavaMerger
« Reply #1 on: September 17, 2009, 06:56 PM »
Now that's interesting!  Is this your creation sindy, or just something you came across? looks pretty cool.

sindy55

  • Participant
  • Joined in 2009
  • *
  • Posts: 2
Re: Convert between C# and Java with CSharpJavaMerger
« Reply #2 on: September 21, 2009, 03:19 AM »
I came across this :). If you're interested, you can join the project too. It is also available at CodePlex:
http://csharpjavamerger.codeplex.com/

Cheers.

jeremejazz

  • hey!
  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 59
Re: Convert between C# and Java with CSharpJavaMerger
« Reply #3 on: October 21, 2009, 02:51 PM »
whoah.. now this is very interesting...  hybrid programming eh?

since the two languages are related, you can merge their source codes...

Original address: https://www.donationcoder.com/forum/index.php?topic=19964.0