博客
关于我
c# lambda表达式 LINQ
阅读量:347 次
发布时间:2019-03-04

本文共 843 字,大约阅读时间需要 2 分钟。

入门

在C#编程中,Func是非常重要的一种功能组合,它允许我们定义匿名函数,简化代码编写。以下是一个简单的示例:

using System;  namespace ConsoleApp5  {      class Program      {          static void Main(string[] args)          {              Func
func = new Func
((int a, int b) => { return a + b; }); int result = func(100, 200); // 300 Console.WriteLine(result); func = new Func
((int x, int y) => { return x * y; }); result = func(2, 3); // 6 Console.WriteLine(result); // 简化1 func = (x, y) => { return x * y; }; // 简化2 func = (x, y) => (x * y); // 6 Console.WriteLine(func(2, 3)); } } }

进阶

C#中的Func函数组合非常强大,它可以支持多种参数类型和返回类型。在实际开发中,Func常用于实现回调、事件处理或复杂逻辑的抽象化表达。通过对Func的理解和实践,你可以逐步掌握更复杂的编程逻辑和设计模式。

转载地址:http://vgce.baihongyu.com/

你可能感兴趣的文章
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>
No new migrations found. Your system is up-to-date.
查看>>
No qualifying bean of type XXX found for dependency XXX.
查看>>
No resource identifier found for attribute 'srcCompat' in package的解决办法
查看>>
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
查看>>
NO.23 ZenTaoPHP目录结构
查看>>
NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
查看>>
Node JS: < 一> 初识Node JS
查看>>
Node-RED中使用JSON数据建立web网站
查看>>
Node-RED中使用node-red-browser-utils节点实现选择Windows操作系统中的文件并实现图片预览
查看>>
Node-RED中实现HTML表单提交和获取提交的内容
查看>>
Node.js 实现类似于.php,.jsp的服务器页面技术,自动路由
查看>>
node.js 怎么新建一个站点端口
查看>>
Node.js 文件系统的各种用法和常见场景
查看>>
node.js 配置首页打开页面
查看>>
node.js+react写的一个登录注册 demo测试
查看>>