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 ...
随机推荐
- TransmitFile下载文件(部分转载)
例子代码: public void Down() { TransmitFile(@"/File/KBPub.zip"); } public void TransmitFile(st ...
- PAT1028—— 人口普查
某城镇进行人口普查,得到了全体居民的生日.现请你写个程序,找出镇上最年长和最年轻的人. 这里确保每个输入的日期都是合法的,但不一定是合理的——假设已知镇上没有超过200岁的老人,而今天是2014年9月 ...
- Java之组合数组1
我们先说"数组",数组是有序数据的集合,数组中的每个元素具有相同的数组名和下标来唯一地确定数组中的元素. 一.一维数组的定义 type arrayName[]; 其中类型(type ...
- WScript.SendKeys()的sendkeys发送组合键以及特殊字符
SendKeys.Send("^+{TAB}"); 使用SendKeys将键击和组合键击发送到活动应用程序.此类无法实例化.若要发送一个键击给某个类并立即继续程序流,请使用Send ...
- cetos 7 常用命令
1. 安装 yum install 2. 可安装查找 yum search 3. 查找文件 whereis 4. 查看文件cat 5. 修改文件vi
- "Could not load file or assembly 'DTcms.Web.UI' or one of its dependencies. 拒绝访问。" 的解决办法
出现的问题提示如下:
- [翻译.每月一译.每日一段]Exploring Fonts with DirectWrite and Modern C++
Windows with C++ Exploring Fonts with DirectWrite and Modern C++ Kenny Kerr DirectWrite is an incred ...
- 分支优化:neg+sbb算术运算代替逻辑跳转
今天在分析一个样本的时候,发现一段代码. // .text:100012DF sub esi, 0B7h // 183 // .text:100012E5 neg esi // .text:10001 ...
- Linux驱动编程--基于I2C子系统的I2C驱动的Makefile
ifeq ($(KERNELRELEASE),) KERNELDIR ?= /lib/modules/$(shell uname -r)/buildPWD := $(shell pwd) TEST = ...
- NSS_08 extjs表单验证
Extjs做了非常好的表单验证功能, 使用起来非常方便. 系统内置了4种验证功能,分别是alpha, alphanumeric,url, email, 在程序中可以直接使用,(可以结合allowBla ...