Jul 15 2009

An example

Published by Kevin Gao at 10:13 pm under C# & Java conversion

This article is a part of CSharpJavaMerger Framework, an open source project. Join us now to make it better!

Below is a piece of code of a method. In the sample, CString, a class defined in the CSharpJavaMerger Framework, is used instead of String. This way, the method AddTwoValues can be used in both C# and Java.

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"));
    }
}

 

Links:
Previous article >>>>: Architecture
Next article >>>>: How to write C# code?
WCF & Java Interop series home page: CSharpJavaMerger Framework

No responses yet

Trackback URI | Comments RSS

Leave a Reply

Version Control Software/System | Source Control Software/System | Software Configuration Management | SCM Hosting Solution | Bug Tracking System
SourceSafe (VSS) Replacement/Alternative | SourceSafe (VSS) Hosting | SourceSafe (VSS) Remote/Web/Internet Access | Scanner COM
Customer Service Software | Live Chat | Live Help | Forum Software | Knowledge Base Software | Newsletter Email Marketing Software