skip to main |
skip to sidebar
Generic with Lamda Expression
public void Each
(IEnumerable items, Action action)
{
foreach (var item in items)
{
action(item);
}
}
public void Main()
{
List myList = new List();
myList.Add(1);
myList.Add(3);
Each(myList, i => textBox1.AppendText(i.ToString()+ "\r\n") );
new List(myList).ForEach(i => textBox1.AppendText(i.ToString() + "\r\n"));
}
No comments:
Post a Comment