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 3666200
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:51:05+00:00 2026-05-19T01:51:05+00:00

I’m not sure if this question has been answered elsewhere and I can’t seem

  • 0

I’m not sure if this question has been answered elsewhere and I can’t seem to find anything through google that isn’t a “Hello World” example… I’m coding in C# .NET 4.0.

I’m trying to develop a console application that will open, display text, and then wait for the user to input commands, where the commands will run particular business logic.

For example: If the user opens the application and types “help”, I want to display a number of statements etc etc. I’m not sure how to code the ‘event handler’ for user input though.

Hopefully this makes sense. Any help would be much appreciated!
Cheers.

  • 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-19T01:51:06+00:00Added an answer on May 19, 2026 at 1:51 am

    You need several steps to achieve this but it shouldn’t be that hard. First you need some kind of parser that parses what you write. To read each command just use var command = Console.ReadLine(), and then parse that line. And execute the command… Main logic should have a base looking this (sort of):

    public static void Main(string[] args)
    {
        var exit = false;
        while(exit == false)
        {
             Console.WriteLine();
             Console.WriteLine("Enter command (help to display help): "); 
             var command = Parser.Parse(Console.ReadLine());
             exit = command.Execute();
        }
    }
    

    Sort of, you could probably change that to be more complicated.

    The code for the Parser and command is sort of straight forward:

    public interface ICommand
    {
        bool Execute();
    }
    
    public class ExitCommand : ICommand
    {
        public bool Execute()
        {
             return true;
        }
    }
    
    public static Class Parser
    {
        public static ICommand Parse(string commandString) { 
             // Parse your string and create Command object
             var commandParts = commandString.Split(' ').ToList();
             var commandName = commandParts[0];
             var args = commandParts.Skip(1).ToList(); // the arguments is after the command
             switch(commandName)
             {
                 // Create command based on CommandName (and maybe arguments)
                 case "exit": return new ExitCommand();
                   .
                   .
                   .
                   .
             }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
This could be a duplicate question, but I have no idea what search terms
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
For some reason, after submitting a string like this Jack’s Spindle from a text
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) 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.