How to remove item from list by index in C#

1 Answer

0 votes
using System;
using System.Collections.Generic;

public class Program
{
	public static void Main()
	{
		List<string> list = new List<string>{"a", "b", "c", "d", "e"};
    	int index = 2;
    
    	list.RemoveAt(index);

    	list.ForEach(Console.WriteLine);
	}
}



/*
run:

a
b
d
e

*/

 



answered Feb 28, 2023 by avibootz

Related questions

1 answer 146 views
1 answer 189 views
1 answer 184 views
1 answer 136 views
1 answer 165 views
1 answer 183 views
1 answer 206 views
...