标签:parameter app style param gate div span str blog
看例子:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
List<string> list = new List<string>(new string[] { "111", "222" });
list.ForEach(delegate (String item) { Console.WriteLine(item); });
Work work = new Work();
list.ForEach(work.doWork);
list.ForEach(
item => work.doWork
(
() => { Console.WriteLine(item); } //this is Action object passed as parameter
)
);
Console.Read();
}
public class Work
{
public void doWork(Action act)
{
act();
Console.WriteLine("Pass in Action");
}
public void doWork(string item)
{
Console.WriteLine(item);
Console.WriteLine("Pass in string");
}
}
}
}
一共可以有3种方法:
标签:parameter app style param gate div span str blog
原文地址:http://www.cnblogs.com/sungang3225/p/7613506.html