Func<string, string> toUpper = x => x.ToUpper();

string[] words = { "aaaa","bbbb","cccc","dddd"};

IEnumerable<string> toWords=words.Select(toUpper);

foreach (var m in toWords)
Console.WriteLine(m);

 

Action<T>泛型委托:封装一个方法,该方法只采用一个参数并且不返回值.

 

 

static void Main(string[] args)
{

Action<User,int> actions = (x, y) => x.SetUser(y);

User u=new User();

actions(u, 1);
Console.Read();
}

 

public class User
{
public void SetUser(int userId)
{
Console.WriteLine(userId);
}
}

相关文章:

  • 2021-06-19
  • 2022-12-23
  • 2021-07-16
  • 2021-07-28
猜你喜欢
  • 2021-08-24
  • 2022-12-23
  • 2022-01-28
  • 2021-06-28
  • 2021-09-23
相关资源
相似解决方案