How to remove a range of elements from a list in C#

1 Answer

0 votes
using System;
using System.Collections.Generic;
					
public class Program
{
	public static void Main()
	{
		var lst = new List<string>() { "python", "c#", "php", "c#", "nodejs", "java", "c" };

        lst.RemoveRange(1, 4);
         
		foreach (string s in lst) {
            Console.WriteLine(s);
        }
	}
}



/*
run:

python
java
c

*/

 



answered May 6, 2020 by avibootz

Related questions

1 answer 112 views
1 answer 148 views
1 answer 149 views
1 answer 177 views
1 answer 139 views
...