public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void txtTestPrime_Click(object sender, EventArgs e)
{
TestPrime myNumber = new TestPrime();
lblAnswer.Text =
myNumber.TestPrime(ToInt16(txtTestPrime.Text)) ? "it is prime!" : "it is NOT prime!";
}
}
public class TestPrime(int number)
{
bool prime;
}
it doesnt like this line:
public class TestPrime(int number)
i am getting this error: invalid token ‘(‘ in class, struct, or interface member declaration
also getting expect { and ; on that line
also on this line:
myNumber.TestPrime(ToInt16(txtTestPrime.Text)) ? "it is prime!" : "it is NOT prime!";
im getting Error 4 ‘WindowsFormsApplication1.TestPrime’ does not contain a definition for ‘TestPrime’ and no extension method ‘TestPrime’ accepting a first argument of type ‘WindowsFormsApplication1.TestPrime’ could be found (are you missing a using directive or an assembly reference?)
perhaps it is one main thing that i am doing wrong. please help!
You are trying to create a class and a method on the same line at the same time, that just don’t make any sense.
If you want a method to check the number, do the following:
Some useful links: