Remove the first occurrence of a specific object from the Collection in CSharp
Description
The following code shows how to remove the first occurrence of a specific object from the Collection.
Example
using System;/*w w w. j a v a 2 s . com*/
using System.Collections.Generic;
using System.Collections.ObjectModel;
public class Demo
{
public static void Main()
{
Collection<string> myData = new Collection<string>();
myData.Add("A");
myData.Add("B");
myData.Add("C");
myData.Add("D");
myData.Remove("A");
foreach( string item in myData )
{
Console.WriteLine(item);
}
}
}
The code above generates the following result.