usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespace_11.流程控制之goto语句{classProgram{staticvoidMain(string[]args){//goto语句用于控制代码何时执行。/***goto语句使用语法:*goto<labelname>;*goto语句标签名定义语法:*<labelname>:*///使用goto语句会导致程序流程混乱,代码不容易阅读。//使用goto语句可能导致有些代码块无法执行。//使用goto语句实现1+...+10累加功能。{inti=1,sum=0;Loop:sum+=i;i++;if(i>10)gotoEnd;gotoLoop;End:Console.WriteLine("sum={0}",sum);}{intmyInteger=5;gotomyLabel;myInteger+=10;//此句代码无法执行myLabel:Console.WriteLine("myInteger={0}",myInteger);}Console.ReadKey();}}}