- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- // 作用 1: 返回值; 作用 2: 立即结束本次方法的执行
namespace _03return 关键字
- {
- class Program
- {static void Main(string[] args)
- {
- while(true)
- {
- Console.WriteLine("Hello world!");
- //break;// 跳出当前循环
- //continue;// 跳到循环条件进行判断
- return;// 直接跳过 main 函数, 立即结束本次方法的执行
- }
- Console.WriteLine("哈哈哈");
- Console.ReadKey();
- }
- }
- }
- C# 中 return 的两个作用
来源: http://www.bubuko.com/infodetail-2596136.html