How to avoid C# console applications from closing automatically.
One way is to interop it with msvcrt.dll
You can pinvoke this C function into your C# application. This process is very easy. There are a few steps:1) Insert System.Runtime.InteropServices to your using clauses.
2) Insert this line in your class (usually in the first few lines)[DllImport("msvcrt.dll")]
static extern bool system(string str);3) In that same class, simply write this:
system("pause");
The simplest way that I always use is to ask for input
Console.ReadLine();
or
Console.ReadKey();
ReadLine() waits for ↩, ReadKey() waits for any key (except for modifier keys).
How to avoid C# console applications from closing automatically.的更多相关文章
- [转]Publishing and Running ASP.NET Core Applications with IIS
本文转自:https://weblog.west-wind.com/posts/2016/Jun/06/Publishing-and-Running-ASPNET-Core-Applications- ...
- Console Event Handling
http://www.codeproject.com/Articles/2357/Console-Event-Handling Console Event Handling Kumar Gaurav ...
- Async All the Way
Asynchronous code reminds me of the story of a fellow who mentioned that the world was suspended in ...
- The week in .NET - 1/12/2015
On.NET Last week, we had Mads Torgersen on the show to talk about language design in general, and C# ...
- Async/Await - Best Practices in Asynchronous Programming
https://msdn.microsoft.com/en-us/magazine/jj991977.aspx Figure 1 Summary of Asynchronous Programming ...
- Don't Block on Async Code【转】
http://blog.stephencleary.com/2012/07/dont-block-on-async-code.html This is a problem that is brough ...
- Git for Windows v2.11.0 Release Notes
homepage faq contribute bugs questions Git for Windows v2.11.0 Release Notes Latest update: December ...
- 小心C# 5.0 中的await and async模式造成的死锁
平时在使用C# 5.0中的await and async关键字的时候总是没注意,直到今天在调试一个ASP.NET项目时,发现在调用一个声明为async的方法后,程序老是莫名其妙的被卡住,就算声明为as ...
- Async/Await - Best Practices in Asynchronous Programming z
These days there’s a wealth of information about the new async and await support in the Microsoft .N ...
随机推荐
- K3Cloud单据转换获取源单数据
private DynamicObject sourceBill = null; object fid; //获取源单数据(选单) public overri ...
- 通过带参数的Sql语句来实现模糊查询(多条件查询)
#region 通过带参数的Sql语句来实现模糊查询(多条件查询) StringBuilder sb = new StringBuilder("select * from books&quo ...
- MVC System.Web.Mvc.ModelClientValidationRule”同时存在
错误 2280 类型“System.Web.Mvc.ModelClientValidationRule”同时存在于“C:\Program Files\Microsoft ASP.NET\ASP.NET ...
- 在Linux下进行磁盘分区
1. 分区前的规划 2. 查看本机上的磁盘信息 3. 对第二个磁盘进行交换式分区操作(输入m为帮助信息) 图 1:n为新建分区 图 2:p为 ...
- AMQ学习笔记 - 07. 持久性订阅
概述 一般的订阅,订阅者必须时刻处于活跃状态,才不会遗漏任何信息:持久性订阅,当订阅者处于非活动状态时,代理会为它们保留信息,下一次连接之后推送给它们. 持久订阅 与一般的定于相比,持久性订阅需要: ...
- error at ::0 can't find referenced pointcut performance
严重: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support. ...
- 判断Featureclass的类型
一个Featureclass可以是Shapefile Feature Class.Personal Geodatabase Feature Class.File Geodatabase Feature ...
- MATLAB学习(3)
matlab读取图像并转化为灰度图像 image = imread('C:\Users\Administrator\Desktop\图像降噪\src\original image\100.png'); ...
- js中隐式类型转换测试
javascript数据类型: 使用typeof可以返回的数据类型有六种 "number" , "string" , "boolean" ...
- Spark菜鸟学习营Day4 单元测试程序的编写
Spark菜鸟学习营Day4 单元测试程序的编写 Spark相比于传统代码是比较难以调试的,单元测试的编写是非常必要的. Step0:需求分析 在测试案例编写前,需完成需求分析工作,明确程序所有的输入 ...