【问题标题】:how to Compare String Array with ListBox items?如何将字符串数组与 ListBox 项进行比较?
【发布时间】:2013-09-16 12:29:36
【问题描述】:

我有

string[] parts = {"Product", "Things"};

ListBox 包含的项目为

1.产品 2.物品 3.事物

我想将部件中的字符串匹配到 ListBox 中的项目。 如果匹配,我想在 ListBox 中选择该项目。
如何做到这一点?请帮帮我

【问题讨论】:

    标签: arrays string listbox c#-3.0 listboxitems


    【解决方案1】:
    string[] parts = { "Product", "Things" };
    
    for (int i = 0; i < parts.Length; i++)
    {
        if (listBox1.Items.Count > i && parts[i] == listBox1.Items[i])
        {
            // match
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-22
      • 1970-01-01
      • 1970-01-01
      • 2016-10-17
      • 2016-04-11
      相关资源
      最近更新 更多