0
using System;

// Namespace
namespace ConsoleApp22
{
    // Main Class
    class Program
    {
        // Entry Point Method
        static void Main(string[] args)
        {
            string name = "Florent Shomora";


            // start here 
            Console.Write("Hello World"+ name);
        }
    }
}

This is my code and the problem is that the console pop up and die.

rene
  • 41,474
  • 78
  • 114
  • 152
  • That code works as advertised. Exit 0 means no errors and there is nothing left to do so the thread ends and so does the process. – rene Dec 14 '17 at 10:31
  • 2
    Possible duplicate of [How to keep console window open](https://stackoverflow.com/questions/16952846/how-to-keep-console-window-open) – Sayse Dec 14 '17 at 10:31

3 Answers3

1

Do you want to see console window ? Try to use Console.Readline()

    static void Main(string[] args)
    {
        string name = "Florent Shomora";


        // start here 
        Console.Write("Hello World"+ name);
        Console.Readline();
    }
lucky
  • 12,734
  • 4
  • 24
  • 46
1

The problem is that your program works without error.

However, what does your program do? It prints a message to the screen, nothing more. This is a very fast operation. The program will complete this operation and terminate probably faster than you can read the message.

You can pause the program by adding another operation which will take more time, such as expecting user input:

string name = "Florent Shomora";

// start here 
Console.Write("Hello World"+ name);

Console.ReadLine();

With that extra call to ReadLine() the application will now remain open and wait for you to press "return" before closing.

David
  • 208,112
  • 36
  • 198
  • 279
1

Try

Console.Readline()

it should show u the Console and u can exit by clicking for example enter

Raizzen
  • 192
  • 13