How to check if a string is in StringCollection with C#

1 Answer

0 votes
using System;
using System.Collections.Specialized; 
                     
public class Program
{
    public static void Main()
    {
        StringCollection sc = new StringCollection(); 
   
        sc.Add("c#"); 
        sc.Add("c++"); 
        sc.Add("java"); 
        sc.Add("php"); 
        sc.Add("python"); 
	 
		Console.WriteLine(sc.Contains("c#")); 
		Console.WriteLine(sc.Contains("nodejs")); 
    }
}
 
 
 
/*
run:
 
True
False
 
*/

 



answered May 9, 2020 by avibootz

Related questions

...