请问关于c的具体应用场景有哪些?

2026-04-29 03:562阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计249个文字,预计阅读时间需要1分钟。

请问关于c的具体应用场景有哪些?

当我在Release模式中运行以下内容时,按下CTRL+C会成功终止该应用程序。在Debug模式中运行时,按下CTRL+C会使程序在底层的while循环中挂起。为什么?有没有解决办法?

csharpstatic void Main(string[] args){ while (true)}

当我在Release中运行以下内容时,按下CTRL C会成功终止该应用程序.

请问关于c的具体应用场景有哪些?

在Debug中运行时,按下CTRL C会在下面的while循环中挂起.

为什么?有没有解决的办法?

static void Main(string[] args) { while (true) { // Press CTRL + C... // When running in Release, the app closes down // When running in Debug, it hangs in here } } 一种方法是实现这一点是使用 Console.CancelKeyPress

Occurs when the Control modifier key (Ctrl) and either the
ConsoleKey.C console key (C) or the Break key are pressed
simultaneously (Ctrl+C or Ctrl+Break).

When the user presses either Ctrl+C or Ctrl+Break, the CancelKeyPress
event is fired and the application’s ConsoleCancelEventHandler event
handler is executed. The event handler is passed a
ConsoleCancelEventArgs object

private static bool keepRunning = true; public static void Main(string[] args) { Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) { e.Cancel = true; keepRunning = false; }; while (keepRunning) { // Do stuff } Console.WriteLine("exited gracefully"); }

本文共计249个文字,预计阅读时间需要1分钟。

请问关于c的具体应用场景有哪些?

当我在Release模式中运行以下内容时,按下CTRL+C会成功终止该应用程序。在Debug模式中运行时,按下CTRL+C会使程序在底层的while循环中挂起。为什么?有没有解决办法?

csharpstatic void Main(string[] args){ while (true)}

当我在Release中运行以下内容时,按下CTRL C会成功终止该应用程序.

请问关于c的具体应用场景有哪些?

在Debug中运行时,按下CTRL C会在下面的while循环中挂起.

为什么?有没有解决的办法?

static void Main(string[] args) { while (true) { // Press CTRL + C... // When running in Release, the app closes down // When running in Debug, it hangs in here } } 一种方法是实现这一点是使用 Console.CancelKeyPress

Occurs when the Control modifier key (Ctrl) and either the
ConsoleKey.C console key (C) or the Break key are pressed
simultaneously (Ctrl+C or Ctrl+Break).

When the user presses either Ctrl+C or Ctrl+Break, the CancelKeyPress
event is fired and the application’s ConsoleCancelEventHandler event
handler is executed. The event handler is passed a
ConsoleCancelEventArgs object

private static bool keepRunning = true; public static void Main(string[] args) { Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) { e.Cancel = true; keepRunning = false; }; while (keepRunning) { // Do stuff } Console.WriteLine("exited gracefully"); }