I've started today with Visual Studio and I'm trying to work with Booleans.
I want to do following thing:
Click on a specific Button - Program opens - set a variable that the program is opened - if that's the case, it'll reopen the programm but close the current before (so the program is not opened twice)
I've already following code:
private void button1_Click(object sender, EventArgs e)
{
bool status = false;
if (status != true)
{
status = true;
System.Diagnostics.Process.Start("C:\\Users\\David\\Desktop\\Test\\Test.exe");
}
}
Now my problems is, if I click always on the button, the variable is set on false as you can see on the first line. How I can do it correctly ?
Also, how I do return 0 if status is set on true?
Thanks for your time
Aucun commentaire:
Enregistrer un commentaire