user3519124
user3519124

Reputation: 69

make c# program an .exe file

I wrote a program that I need to use without the Visual Studio. I found the .exe file from the debug folder in the bin folder, I tried to use it but it closed just after I tried.

What do I need to do in order to keep it open after it finishes?

Thank you :)

Upvotes: 0

Views: 383

Answers (3)

Guilherme Oliveira
Guilherme Oliveira

Reputation: 2026

You can write this after your code:

Console.ReadKey();

or

Console.ReadLine();

or even

Console.Read();

It will close when you press any key.

Upvotes: 3

DidIReallyWriteThat
DidIReallyWriteThat

Reputation: 1033

Add a readkey at the end of a console application to have the window stay open untill you press any key

Console.ReadKey();

Upvotes: 0

konkked
konkked

Reputation: 3231

Put a ReadLine at the end of the program

public class Program
{
    public void Main(string[] args)
    {
        /*Program logic*/
        Console.WriteLine("Press enter to continue...");
        Console.ReadLine();
    }
}

Upvotes: 0

Related Questions