I added following code to my C# windows form application to show a message box when i click the closing button.. But it gives me following error..
Error CS0116 A namespace cannot directly contain members such as fields or methods ebay source C:\Users\Supun\Documents\Visual Studio 2015\Projects\ebay source\ebay source\Form1.cs 107 Active
this is the code i used..
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult dialog = dialog = MessageBox.Show(
"Do you really want to close the program?",
"SomeTitle",
MessageBoxButtons.YesNo);
if (dialog == DialogResult.No)
{
e.Cancel = true;
}
}
What do I need to do to fix it please?