using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GotoDemo
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入需要查找的文字:");
string inputstr = Console.ReadLine(); string[] mystr = new string[5];
mystr[0] = "zifubao";
mystr[1] = "weixin";
mystr[2] = "QQ";
mystr[3] = "yinlian";
mystr[4] = "jingdong";
for (int i = 0; i < mystr.Length; i++)
{
if (mystr[i].Equals(inputstr))
{
goto Found;
}
}
Console.WriteLine("您查找的{0}不存在!", inputstr);
goto Finish;
Found:
Console.WriteLine("您查找的{0}存在!", inputstr);
Finish:
Console.WriteLine("查找完毕");
Console.ReadLine();
}
}
}
GOTO的用法如下
最新推荐文章于 2024-08-16 20:07:09 发布