programming-examples/c-sharp/Linq/C# Sharp to Remove Items from List by passing the item index.cs

35 lines
1.2 KiB
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class LinqExercise20
{
static void Main(string[] args)
{
List<string> listOfString = new List<string>();
listOfString.Add("m");
listOfString.Add("n");
listOfString.Add("o");
listOfString.Add("p");
listOfString.Add("q");
Console.Write("\nLINQ : Remove Items from List by passing item index : ");
Console.Write("\n--------------------------------------------------\n");
var _result1 = from y in listOfString
select y;
Console.Write("Here is the list of items : \n");
foreach(var tchar in _result1)
{
Console.WriteLine("Char: {0} ", tchar);
}
listOfString.RemoveAt(3);
var _result = from z in listOfString
select z;
Console.Write("\nHere is the list after removing item index 3 from the list : \n");
foreach(var rChar in _result)
{
Console.WriteLine("Char: {0} ", rChar);
}
Console.ReadLine();
}
}