当前位置: 首页 > news >正文

17网站一起做网店河北惠城网站设计

17网站一起做网店河北,惠城网站设计,郑州高端网站制作,北京网站建设公司Action<>是.NET Framework中自带的泛型委托&#xff0c;可以接收一个或多个输入参数&#xff0c;但不返回任何参数&#xff0c;可传递至多16种不同类型的参数类型。在Linq的一些方法上使用的比较多。 1、Action泛型委托 .NET Framework为我们提供了多达16个参数的Action…

Action<>是.NET Framework中自带的泛型委托,可以接收一个或多个输入参数,但不返回任何参数,可传递至多16种不同类型的参数类型。在Linq的一些方法上使用的比较多。

 

1、Action泛型委托

.NET Framework为我们提供了多达16个参数的Action委托定义,对于常见的开发场景已经完全够用。

如下图,

示例说明:

Action<>:委托至少0个参数,至多16个参数,无返回值。

Action:表示无参,无返回值的委托。

Action :表示有传入参数int,string无返回值的委托。

Action:表示有传入参数int,string,bool无返回值的委托。

Action:表示有传入4个int型参数,无返回值的委托。

2、Action泛型委托的使用

Action泛型委托的使用方法,可以通过下面代码看一下,

例如,

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ActionDemo
{class Program{static void Main(string[] args){// 无参数无返回值的委托Action action1 = new Action(ActionWithNoParaNoReturn);action1();Console.WriteLine("----------------------------");// 使用delegateAction action2 = delegate { Console.WriteLine("使用delegate"); };// 执行action2();Console.WriteLine("----------------------------");// 使用匿名委托Action action3 = () => { Console.WriteLine("匿名委托"); };action3();Console.WriteLine("----------------------------");// 有参数无返回值的委托Action<int> action4 = new Action<int>(ActionWithPara);action4(11);Console.WriteLine("----------------------------");// 使用delegateAction<int> action5 = delegate (int i) { Console.WriteLine($"使用delegate的委托,参数值是:{i}"); };action5(22);Console.WriteLine("----------------------------");// 使用匿名委托Action<string> action6 = (string s) => { Console.WriteLine($"使用匿名委托,参数值是:{s}"); };action6("C#");Console.WriteLine("----------------------------");// 多个参数无返回值的委托Action<int,string> action7 = new Action<int,string>(ActionWithMulitPara);action7(33, "Java");Console.WriteLine("----------------------------");// 使用delegateAction<int,int,string> action8 = delegate (int i1, int i2, string s) {Console.WriteLine($"三个参数的Action委托,参数1的值是:{i1},参数2的值是:{i2},参数3的值是:{s}");};action8(44, 55, "Python");Console.WriteLine("----------------------------");Action<int,int,string,string> action9 = (int i1,int i2, string s1,string s2) => {Console.WriteLine($"使用四个参数的委托,参数1的值是:{i1},参数2的值是:{i2},参数3的值是:{s1},参数4的值是:{s2}");};// 执行委托action9(66,77, "C","CJavaPy");Console.ReadKey();}static void ActionWithNoParaNoReturn(){Console.WriteLine("无参数无返回值的Action委托");}static void ActionWithPara(int i){Console.WriteLine($"有参数无返回值的委托,参数值是:{i}");}static void ActionWithMulitPara(int i,string s){Console.WriteLine($"有两个参数无返回值的委托,参数1的值是:{i},参数2的值是:{s}");}}
}

 

http://www.ds6.com.cn/news/82873.html

相关文章:

  • 做试卷的网站免费投放广告的平台
  • 小型教育网站的开发建设开题报告网站域名注册查询
  • 企业所得税计算公式2022seo优化师就业前景
  • 低价网站建设要多少钱百度爱采购
  • 学习建设网站书籍权威解读当前经济热点问题
  • 如何登录网站服务器模板建站公司
  • 都有哪些可以做app的网站百度推广官网
  • 绵阳房产网站建设人教版优化设计电子书
  • 企业网站带数据库友链交换平台
  • 做生存分析的网站山东做网站公司
  • 做导航网站用什么cms2022年搜索引擎优化指南
  • 公安网站管理系统破解深圳网络推广有几种方法
  • 有域名了网站怎么建设想做seo哪里有培训的
  • 自己做网站的费用百度推广渠道户
  • 智慧工业园区建设方案关键词优化推广公司
  • wordpress 商品模板下载福州百度网站快速优化
  • 电商平台技术开发方案快抖霸屏乐云seo
  • 商务网站管理的主要内容数据管理杭州网站seo推广
  • 免费网站seo sem是什么职位
  • 为什么选择网站来做论文题目营销型企业网站有哪些平台
  • 线下引流推广方法网站优化就是搜索引擎优化
  • 自己做网站怎么优化宁波seo排名外包
  • 网站域名及空间购买国内专业的seo机构
  • 济南行业网站开发百度网址安全检测
  • 宁波网站建设制作网络公司广告营销留电话网站
  • 福州做网站公司有哪些广州百度推广外包
  • 网站在淘宝上做靠谱吗千锋教育培训多少钱
  • 成都活动轨迹seo专员
  • 各网站封面尺寸长尾关键词挖掘
  • 杭州口碑好的电商有哪些公司win10优化工具