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 ...
随机推荐
- Asp.Net-创建网站的快捷方式到桌面,开始菜单,收藏夹
/// <summary> /// 创建快捷方式 /// </summary> /// <param na ...
- markdownpad2使用说明
## 欢迎使用 MarkdownPad 2 ## **MarkdownPad** 是 Windows 平台上一个功能完善的 Markdown 编辑器. ### 专为 Markdown 打造 ### 提 ...
- Elementary os的安装
1. 使用安装文件进行数据读取 2. 进入安装界面 3. 选择语言并进行安装(可以先试用) 4. 选择继续(可以勾选两个选项,意思是 ...
- OSPF路由汇总和默认路由设置
目标 掌握OSPF路由汇总的配置 掌握OSPF默认路由的配置 一.——区域间汇总 配置IP,R2四个环回口 R1(config)#inter s1/0 R1(config-if)#ip add 200 ...
- Sql日期时间格式转换;取年 月 日,函数:DateName()、DATEPART()
一.sql server2000中使用convert来取得datetime数据类型样式(全) 日期数据格式的处理,两个示例: CONVERT(varchar(16), 时间一, 20) 结果:2007 ...
- (转)RabbitMQ消息队列(六):使用主题进行消息分发
在上篇文章RabbitMQ消息队列(五):Routing 消息路由 中,我们实现了一个简单的日志系统.Consumer可以监听不同severity的log.但是,这也是它之所以叫做简单日志系统的原因, ...
- <img>元素底部为何有空白?
原因: 图片文字等inline元素默认是和父级元素的baseline对齐的,即:vertical-align 的默认值是 baseline:而baseline又和父级底边bottom有一定距离: im ...
- WebServiceException
在用cxf做webservice的时候,在写客户端程序的时候,出现以下异常: Could not find wsdl:binding operation info for web method tes ...
- MFC控件随窗口大小变化原理及实现
本文主要针对MFC的dialog,实现控件随窗口大小变化. 原理:首先获取dialog的初始大小,当窗口发送变动时,调用OnSize事件和方法,计算缩放比例,然后对界面中的所有控件进行缩放和布局. 实 ...
- Allegro设置十字大光标
使用大十字光标,在摆放元器件时,容易对齐.在allegro中,可以通过设置实现大十字光标,其具体方法如下: 1.选择Setup->User Perferences,即可出现如下图所示界面: 2. ...