Programming, website development forum Get latest updates by RSS Follow TechnicalTalk on Twitter Follow TechnicalTalk on Facebook 
HomeSearchRecent PostsLoginRegisterContact Us

Username  
Password    
  Forgot your password?  

Pages: [1]   Go Down
 
  Email this topic  |  Print
0 Members and 1 Guest are viewing this topic.

Convert between C# and Java with CSharpJavaMerger

 
webmaster forum
sindy55  Offline
Activity
0%
 
New Poster
Posts: 1
Topics: 1
September 09, 2009, 02:19:13 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.

Code:
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
« Last Edit: July 09, 2011, 07:50:35 PM by Admin »
 
webmaster forum
polas  Offline
Activity
33.33%
 
Code Guru
Gender: Male
Posts: 1399
Topics: 85
WWW
September 09, 2009, 03:58:27 AM

Is it possible to integrate this easily into existing code - i.e. why not override methods of String and do it that way, then the programmer need not change all instances of String to CString

Mesham Type Oriented Parallel Programming Language, Free online technical support
 
  Email this topic  |  Print
Pages: [1]   Go Up
 
Jump to:  



Powered by SMF 1.1.15 | SMF © 2011, Simple Machines


Google visited last this page February 05, 2012, 11:35:27 AM