You are probably running the application in debug, without something to prevent it to close as soon as the job gets done.
Basically, your code executes, and the application shuts because there is nothing else left to do.
Two solutions:
- do as Štěpán Šubík recommands : put a
Console.ReadKey()
; - start the application without debugging (Ctrl+F5 or menu Debug -> Start Without Debugging).
In both case, the console won’t close itself automatically :).
solved “Hello world” c# program appear for a split of a second with Visual Studio [closed]