• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:

c# stop running

How can i make a condition in c#

if (count < 10)

then stop running program
using (MySqlCommand cmd = new MySqlCommand("SELECT COUNT( * ) FROM  `member`  WHERE  `tambol` LIKE  '¿¿¿¿¿¿¿' ", conDatabase))
                {
                    try
                    {


                        long count = (long)cmd.ExecuteScalar();
                    

                        Console.WriteLine(count.ToString());

                        if (count < 10)
                        {
                            exit ;
                        }

                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }

Open in new window

0
teera
Asked:
teera
4 Solutions
 
Kiran SonawaneProject LeadCommented:
Try return; instead of exit;
0
 
Pratima PharandeCommented:
Try break; instead of exit;

 if (count < 10)
                        {
                           break;
                        }

0
 
AndyAinscowFreelance programmer / ConsultantCommented:
use  
          Application.Exit();
instead of exit;
0
 
sachinpatil10dCommented:
break;                        //The break statement terminates the closest enclosing loop
return;                       //will exit the current method
Application.Exit();       //exit the application use
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now