I just started nightschool to learn c# (learn programming at all)
We got an exercise where we need to test for a palindrome
We were asked to put the test in a function and then call the result in a messagebox.
I'm kinda stuck on the last part the calling.
Here's what I have so far:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Pallindroom_testen
{
public partial class frmPallindroom : Form
{
string strWoord1 = "";
public frmPallindroom()
{
InitializeComponent();
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
private string controle(string sControle)
{
strWoord1 = txtWoord.Text;
int iTeller = strWoord1.Length;
string strWoord2 = "";
string strControle = "";
for (int iI = 1; iI < iTeller + 1; iI++)
{
strWoord2 += strWoord1.Substring(iTeller - iI, 1);
}
if (strWoord2.Equals(strWoord1))
strControle = "Het woord " + strWoord1 + " is een pallindroom";
else
strControle = "Het woord " + strWoord1 + " is geen pallindroom";
return strControle;
}
private void btnTest_Click(object sender, EventArgs e)
{
MessageBox.Show(controle(sControle).ToString);
}
}
}
Any ideas?