发布时间:2025-12-09 12:06:04 浏览次数:2
在这里,我们将了解 Environment 类的 Exit() 方法。此方法用于终止当前进程并向操作系统返回指定的退出代码。
用法:
void Environment.Exit(int exitcode);
参数:
返回值:
此方法不返回任何值。
异常:
程序:
下面给出了演示使用 Environment 类的 Exit() 方法的源代码。给定的程序已成功编译并执行。
using System;class Sample{ //Entry point of Program static public void Main() { Console.WriteLine("Before Exit Function"); Environment.Exit(0); Console.WriteLine("After Exit Function"); }}输出:
Before Exit FunctionPress any key to continue . . .