Jul 15 2009
An example
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
