首页 > 其他分享 >实例034 使用goto语句在数组中搜索指定图书

实例034 使用goto语句在数组中搜索指定图书

时间:2022-11-03 09:56:42浏览次数:51  
标签:语句 goto C# Text System str using array 034

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _034
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
lbox_str.Items.AddRange(G_str_array);//将数组元素罗列在listbox空间中,将现有的项添加到listbox1中;
}
string[] G_str_array = new string[]
{
"C#范例宝典",
"C#编程宝典",
"C#视频学",
"C#项目开发全程实录",
"C#项目开发实例自学手册",
"C#编程词典",
"C#实战宝典",
"C#经验技巧宝典",
"C#入门模式"
};
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
// lbox_str.Items.AddRange(G_str_array);
}

private void bt_query_Click(object sender, EventArgs e)
{
int i = 0;
label1:
if(G_str_array[i].Contains(textbox.Text))

{
lbox_str.SelectedIndex = i;
MessageBox.Show(textbox.Text + "已经找到", "提示");
return;
}
i++;
if (i < G_str_array.Length) goto label1;
MessageBox.Show(textbox.Text + "没有找到","提示");

}

private void txt_query_TextChanged(object sender, EventArgs e)
{

}
}
}

标签:语句,goto,C#,Text,System,str,using,array,034
From: https://www.cnblogs.com/jiayuan2540/p/16853424.html

相关文章

  • explain分析sql 语句字段的解释和含义
    执行后基本信息  idselect查询的序列号,包含一组可以重复的数字,表示查询中执行sql语句的顺序。一般有三种情况:第一种:id全部相同,sql的执行顺序是由上至下;第二种:id......
  • 实验3 C语言控制语句应用编程
    #include<stdio.h>#include<stdlib.h>#include<time.h>#include<windows.h>#defineN80voidprint_text(intline,intcol,chartext[]);voidprint_spaces......
  • 求和及求平均-while循环语句的应用-2022-11-2
    packagescanner;importjava.util.Scanner;publicclassDemo04{publicstaticvoidmain(String[]args){Scannerscanner=newScanner(System.in);......
  • 条件语句
    一:if...else...1packagemain23import"fmt"45funcmain(){6varnum=107varnum2=208res:=test(num,num2)9fmt.Prin......
  • python 中 if语句取反
     001、>>>str1=">aabbcc">>>ifstr1.startswith(">"):...print("yes")...yes>>>ifnotstr1.startswith(">"):##python中if语句取反...prin......
  • 实验2 C语言控制语句应用编程
    实验任务一:task1.c1#include<stdio.h>2#include<time.h>3#include<windows.h>4#include<stdlib.h>5#defineN306voidprint_spaces(int);7voi......
  • 1034 有理数四则运算
    本题要求编写程序,计算2个有理数的和、差、积、商。输入格式:输入在一行中按照 a1/b1a2/b2 的格式给出两个分数形式的有理数,其中分子和分母全是整型范围内的整数,负号......
  • shell脚本:条件语句
    导图1.条件测试1.1test命令测试格式1:test条件表达式格式2:[条件表达式]1.2test操作符-d:测试是否为目录(Directory)-e:测试目录或文件是否存在(Exist)-a:测试目录......
  • MySQL基础语句
    DDL(DataDefinitionLanguage) DML(DataManipulateLanguage) DQL(DataQueryLanguage)聚合函数聚合函数作用于字段,而且NULL值不参与计算分组查询 具体......
  • 数据库常用语句
    https://blog.csdn.net/weixin_55972781/article/details/118399532创建表CREATETABLEtable1(materialIdTEXT,resourceTypeTEXT,localPathTEXT,remoteUrlTEX......