How to remove the first occurrence of a specific string from StringCollection in C#

1 Answer

0 votes
using System;
using System.Collections.Specialized; 

public class Program
{
    public static void Main()
    {
		String[] arr = new String[] { "c#", "c++", "c", "php", "c++" }; 

		StringCollection sc = new StringCollection(); 
        sc.AddRange(arr); 
		
		sc.Remove("c++"); 
  
        foreach (string s in sc) {
            Console.WriteLine(s);
        }
    }
}



/*
run:
 
c#
c
php
c++
 
*/
  

 



answered May 8, 2020 by avibootz

Related questions

1 answer 177 views
1 answer 135 views
1 answer 145 views
1 answer 227 views
1 answer 150 views
...