Use Anonymous Methods with Find in CSharp
Description
The following code shows how to use Anonymous Methods with Find.
Example
using System;/*from w ww . j a va 2s . com*/
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
class Program
{
static void Main(string[] args)
{
List<string> myList1 = new List<string>();
myList1.Add("A");
myList1.Add("B");
myList1.Add("C");
myList1.Add("D");
string vanilla1 = myList1.Find(delegate(string icecream)
{
return icecream.Equals("B");
});
Console.WriteLine(vanilla1);
}
}
The code above generates the following result.