goto

作者:追风剑情 发布于:2014-8-30 20:46 分类:C#

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace gotoTest
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. switch(2){
  13. case 1:
  14. Console.WriteLine("case 1");
  15. break;
  16. case 2:
  17. goto case 1;
  18. break;
  19. }
  20.  
  21. for (int i = 0; i < 100; i++)
  22. for (int j = 0; j < 100; j++)
  23. if (j == 3)
  24. goto OutFor;
  25. else
  26. Console.WriteLine("i="+i+", j="+j);
  27.  
  28. OutFor: //标记语句
  29.  
  30. Console.WriteLine("完毕!");
  31. Console.ReadKey();
  32. }
  33. }
  34. }

运行结果

goto.png

标签: C#

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号