How to case insensitive check if list contains a string in C#

1 Answer

0 votes
using System;
using System.Linq;
using System.Collections.Generic;
    
class Program
{
    static void Main() {
        var list = new List<string> { "python", "c-sharp", "c", "c++", "java", "php", "go" };
    
        Console.WriteLine(list.Contains("JAVA", StringComparer.InvariantCultureIgnoreCase));
    }
}
    
    
    
    
/*
run:
       
True
     
*/

 



answered Aug 11, 2023 by avibootz

Related questions

...