Check if a Windows ListBox contains a string c# ignorecase?

This question already has an answer here:

  • Case insensitive 'Contains(string)' 22 answers
  • Case-Insensitive List Search 6 answers

  • 如果您的lstFieldData只包含大写字母或小写字母,则可以使用.ToUpper()或.ToLower()。

    lstFieldData
        A
        B
        C
        D
    
        if (!lstFieldData.Items.Contains(ItemValue.ToUpper()))
                MessageBox.Show(ItemValue + "Item not found.");
    lstFieldData
    a
    b
    c
    d
        if (!lstFieldData.Items.Contains(ItemValue.ToLower()))
                MessageBox.Show(ItemValue + "Item not found.");
    

    if (strCompare.Equals("testcompare", StringComparison.InvariantCultureIgnoreCase))
    {
    ///
    }
    

    尝试这个

    链接地址: http://www.djcxy.com/p/13092.html

    上一篇: LINQ中不敏感的字符串匹配在哪里

    下一篇: 检查Windows ListBox是否包含字符串c#ignorecase?