Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6568403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:28:24+00:00 2026-05-25T14:28:24+00:00

This should be straightforward. I just need to simply exit my commandline c# program

  • 0

This should be straightforward. I just need to simply exit my commandline c# program – no fancy stuff.

Should I use

Environment.Exit();

or

this.Close();

or something else?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:28:24+00:00Added an answer on May 25, 2026 at 2:28 pm

    Use return; in your Main method.
    If you aren’t in the main method when you decide to exit the program, you need to return from the method that Main method currently executes.

    Example:

    void Main(...)
    {
        DisplayAvailableCommands();
        ProcessCommands();
    }
    
    void ProcessCommands()
    {
        while(true)
        {
            var command = ReadCommandFromConsole();
            switch(command)
            {
                case "help":
                    DisplayHelp();
                    break;
                case "exit":
                    return;
            }
        }
    }
    

    This is not really an example of good overall design of a console application, but it illustrates the point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question should be quite straightforward, maybe stupid but I just can't find the
It seems like this should be straightforward but I'm boggling. I've got my listview
This should be pretty straightforward I would think. I have this string: [quote=Joe Johnson|1]Hi![/quote]
This might be something very straight forward and I really think it should work
This should be a straightforward question, but I haven't found a clear answer yet.
This should be pretty straightforward, but I can't seem to find an explanation anywhere
This should be straightforward. I have three tables (relevant columns shown). users : ID,USERNAME,PWD
This should be straight forward for a guru. I don't have any code really
Shouldn't this be a pretty straightforward operation? However, I see there's neither a size()
This seems like it should be pretty straight forward, but I'm apparently confused. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.