List<string> s = new List<string>();
s.Add("1");
s.Add("2");
s.Add("3");
s.Add("4");
s.Add("5");
s.Add("6");
s.Add("7");
s.Add("8");
s.Add("9");
s.Add("10");
s.RemoveRange(5, 5); // RemoveRange has two inputs input1 specify from stating index and input 2 specify how many elements you want to delete after the given index
i.e if will give s.RemoveRange(5, 5); then list has only 1,2,3,4,5 i.e this will remove 5 elements after five
and if will give s.RemoveRange(5, 2); then list has only 1,2,3,4,5,8,9,10 i.e this will remove 2 elements after five
The below code will resolve you issue dynamically
s.RemoveRange(5, s.Count-5);
Thanks & Rgards,
Dhiren Kumar Kaunar
Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator