using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions; namespace ConsoleApp3
{
static class Program
{
delegate string delagateA(string paramA); static void Main(string[] args)
{
delagateA delagatea = (a) =>
{
return "delegate方式输出:" + a;
};
Console.WriteLine(delagatea("")); Func<int, int, int> funcA = (paramA, paramB) => paramA + paramB;
Console.WriteLine("Func方式输出:"+funcA(, )); Func<int, int, int> funcB = (paramA, paramB) =>
{
int a = paramA + paramB;
return a;
};
Console.WriteLine("Func方式输出:" + funcB(, )); Action<int, int> actionA = (paramA, paramB) => Console.WriteLine("Action方式输出:" + paramA + paramB);
actionA(, ); Expression<Action<int>> expressionA = paramA => Console.WriteLine("Expression方式输出:" + paramA);
expressionA.Compile()(); Expression<Func<int, int>> expressionB = paramA => paramA;
Console.WriteLine("Expression方式输出:" + expressionB.Compile()()); myFun("chenyishi", c =>
{
return c;
});
} static void myFun(string str, Func<string, string> func)
{
Console.WriteLine("Func作为参数方式输出:"+func(str));
} }
}

delegate Func Action Expression的更多相关文章

  1. C#中匿名函数、委托delegate和Action、Func、Expression、还有Lambda的关系和区别

    以前一直迷迷糊糊的,现在总算搞明白. Lambda表达式 Lamda表达式基本写法是()=>{ };Lambda和方法一样都可以传入参数和拥有返回值.(int x)=>{return x; ...

  2. C# delegate event func action 匿名方法 lambda表达式

    delegate event action func 匿名方法 lambda表达式 delegate类似c++的函数指针,但是是类型安全的,可以指向多个函数, public delegate void ...

  3. 浅谈C#中常见的委托<Func,Action,Predicate>(转)

    一提到委托,浮现在我们脑海中的大概是听的最多的就是类似C++的函数指针吧,呵呵,至少我的第一个反应是这样的. 关于委托的定义和使用,已经有诸多的人讲解过,并且讲解细致入微,尤其是张子阳的那一篇.我就不 ...

  4. C#基础-Func,Action

    Func,Action 的介绍及其用法 Func是一种委托,这是在3.5里面新增的,2.0里面我们使用委托是用Delegate,Func位于System.Core命名空间下,使用委托可以提升效率,例如 ...

  5. [转载]C#基础-Func,Action

    Func,Action 的介绍及其用法 Func是一种委托,这是在3.5里面新增的,2.0里面我们使用委托是用Delegate,Func位于System.Core命名空间下,使用委托可以提升效率,例如 ...

  6. 系统内置委托:Func/Action

    lSystem.Func 代表有返回类型的委托 lpublic delegate TResult  Func<out TResult>(); lpublic delegate TResul ...

  7. C# Task中的Func, Action, Async与Await的使用

    在说Asnc和Await之前,先说明一下Func和Action委托, Task任务的基础的用法 1. Func Func是一种委托,这是在3.5里面新增的,2.0里面我们使用委托是用Delegate, ...

  8. C#的泛型委托Predicate/Func/Action

    Predicate<T> 是一个委托,它代表了一个方法,它的定义是: namespace System {    // 摘要:    表示定义一组条件并确定指定对象是否符合这些条件的方法. ...

  9. 关于 wpf 的ICommand 的 CanExecute CanExecuteChanged func action的认识

    关于 wpf 的ICommand 的 CanExecute CanExecuteChanged  func  action的认识

随机推荐

  1. windows服务器审核失败消息:事件ID: 861 进程标识符:904

    事件ID: 861   进程标识符:904 排查方法: win+R键调出运行窗口, 输入cmd 输入tasklist  /SVC /FI “PID eq 904” 查找进程号904对应的是不是dhcp ...

  2. haproxy启动时提示失败

    haproxy启动时提示失败:[ALERT] 164/110030 (11606) : Starting proxy linuxyw.com: cannot bind socket 这个问题,其实就是 ...

  3. 取当前时间,格式为,yyyy-mm-dd hh:mm:ss

    function CurentTime() { var now = new Date(); var year = now.getFullYear(); //年 var month = now.getM ...

  4. mysql忘记root密码的处理方法

    在linux下,如果忘记了mysql中root用户的密码可以采用以下办法解决. 1. 修改my.cnf,加入skip-grant-tables 修改mysql的配置文件my.cnf,在[mysqld] ...

  5. 前端自动化之webstrom

    前端自动化之webstrom 在刚接触前端的时候,使用的就一直是webstrom,版本是webstrom 8. 前端自动画使用的时候,因为webstrom 8版本是没有集成gulp的.所以每次使用都默 ...

  6. MySQL: [Err] 1093 - You can't specify target table 'bk' for update in FROM clause

    错误的意思说,不能先select出同一表中的某些值,再update这个表(在同一语句中). 例如下面这个sql: delete from tbl where id in (        select ...

  7. ffmpeg设置avformat_open_input( )超时 -stimeout

    ffmpeg用avformat_open_input()解析网络流时,默认是阻塞的. 当遇到解析错误的网络流时,会导致该函数长时间不返回. 为此可以设置ffmpeg的-stimeout 的参数,要注意 ...

  8. mysql数据库中插入表情4个字节的

    这个问题,原因是UTF-8编码有可能是两个.三个.四个字节.Emoji表情或者某些特殊字符是4个字节,而Mysql的utf8编码最多3个字节,所以数据插不进去. 我的解决方案是这样的 1.在mysql ...

  9. 使用Layered Window遇到的一些问题及解决方法

    1. 使用Layered Window需要设置 WS_EX_LAYERED 属性 2.  Layered Window不能作为Child Window 3. 它也不能包含子窗口,为什么呢,因为它收不到 ...

  10. WCF4.0 –- RESTful WCF Services

    转自:http://blog.csdn.net/fangxinggood/article/details/6235662 WCF 很好的支持了 REST 的开发, 而 RESTful 的服务通常是架构 ...