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. MyBatis 一对一(OneToOne)__SELECT

    1.创建SQL脚本: CREATE TABLE t_person(  id int(3) not null auto_increment,  name varchar(20) default null ...

  2. 圆周率的现代计算机求法(C语言) Lebal:research

    C语言求圆周率π 公式法1 #include <stdio.h> #include <math.h> int main(){ float term,result=1; int ...

  3. Java-Runoob:Java 修饰符

    ylbtech-Java-Runoob:Java 修饰符 1.返回顶部 1. Java 修饰符 Java语言提供了很多修饰符,主要分为以下两类: 访问修饰符 非访问修饰符 修饰符用来定义类.方法或者变 ...

  4. springboot成神之——spring jdbc的使用

    本文介绍spring jdbc的使用 目录结构 pom配置 properties配置 model层User类 Dao层QueryForListDao config层AppConfiguration 程 ...

  5. Flask之RESTful

    5.4 Restful 2000年,Roy Thomas Fielding博士在他的博士论文<Architectural Styles and the Design of Network-bas ...

  6. Springboot热部署(热部署原理)和用IDEA开发需要的配置

    热部署原理 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>s ...

  7. HIVE UDF

    基本函数 SHOW FUNCTIONS; DESCRIBE FUNCTION <function_name>; 日期函数 返回值类型 名称 描述 string from_unixtime( ...

  8. delphi 四舍五入

    trunc取整 四舍五入 formatfloat('0.00', 2.1850) 看第二位,然后对后面的数字处理,偶数的话舍去,奇数四舍五入 System.Math.RoundTo(tempval,- ...

  9. sql server生成递归日期、连续数据

    WITH Date AS ( SELECT CAST('2008-08-01' AS DATETIME) da UNION ALL FROM Date WHERE da < '2008-08-2 ...

  10. Django中favicon.ico文件的配置

    默认情况下,浏览器访问一个网站的时候,同时还会向服务器请求“/favicon.ico”这个URL,目的是获取网站的图标. 若没有配置的话,Django就会返回一个404错误,并且浏览器接收到这个404 ...