C#中return的两个作用

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();

}
}
}

猜你喜欢

转载自www.cnblogs.com/tsh292278/p/9023424.html
今日推荐