首页 > 编程语言 >C#中=>语法

C#中=>语法

时间:2022-08-25 13:33:48浏览次数:58  
标签:运算符 C# 左移 语法 int 表达式 Lambda

一、 From to:    https://blog.csdn.net/qq_41598072/article/details/124017274

=>Lambda表达式
参数=>关于参数的函数

举例:

Func<int, int> Add = (x, y) => x + y;
int Out = Add(3,3); //Out = 6

 

 

 

二、From to:    https://zhidao.baidu.com/question/348193306.html

 

"=>"在C#中就叫做Lamda运算符,读作goes to 

用处:msdn里面说用来将左侧的输入变量与右侧的lambda体分离。

左移操作符,将第一个操作数向左移动第二个操作数指定的位数,空出的位置补0。

左移相当于乘,左移一位相当于乘2;左移两位相当于乘4;左移三位相当于乘8。

如:

x<<1= x*2

x<<2= x*4

x<<3= x*8

x<<4= x*16

 

 

扩展资料:

C#的Lambda 表达式都使用 Lambda 运算符 =>,该运算符读为“goes to”。语法如下:

(object argOne, object argTwo) => {; /*Your statement goes here*/}

函数体多于一条语句的可用大括号括起。

类型

可以将此表达式分配给委托类型,如下所示:

delegate int del(int i);

del myDelegate=x=>{return x*x;};

int j = myDelegate(5); //j=25

创建表达式目录树类型:

using System.Linq.Expressions;

//...

Expression <del>=x=>x*x;

=> 运算符具有与赋值运算符 (=) 相同的优先级,并且是右结合运算符。

参考资料来源:百度百科-Lambda表达式

标签:运算符,C#,左移,语法,int,表达式,Lambda
From: https://www.cnblogs.com/changbaishan/p/16623988.html

相关文章

  • atcoder
    \(ARC143\)A给定三个整数,一次可以将两个数或三个数减一,问最少几步能减完。设一开始三个数为\(A,B,C(A\leqB\leqC)\),如果\(A+B<C\),那么说明一定是无法满足条件的......
  • course
    Coursemayreferto:DirectionsornavigationCourse(navigation),thepathoftravelCourse(orienteering),aseriesofcontrolpointsvisitedbyorienteers......
  • couple
    Coupleorcouplesmayreferto:Couple(mechanics),asystemofforceswitharesultantmomentbutnoresultantforceCouple(relationship),twopeopletowh......
  • coupon
    Inmarketing,acouponisaticketordocumentthatcanberedeemedforafinancialdiscountorrebatewhenpurchasingaproduct.Customarily,couponsareissu......
  • 【Android Studio】未找到SDK位置:SDK location not found. Define location with an A
    编译时遇到问题:SDKlocationnotfound.DefinelocationwithanANDROID_SDK_ROOTenvironmentvariableorbysettingthesdk.dirpathinyourproject'slocalpro......
  • courage
    Courage(alsocalledbraveryorvalour)isthechoiceandwillingnesstoconfrontagony,pain,danger,uncertainty,orintimidation.Physicalcourageisbraver......
  • NC14661 简单的数据结构
    题目原题地址:简单的数据结构题目编号:NC14661题目类型:双端队列时间限制:C/C++1秒,其他语言2秒空间限制:C/C++131072K,其他语言262144K1.题目大意双端队列的应用2.......
  • ItemRank: A Random-Walk Based Scoring Algorithm for Recommender Engines
    目录概符号说明本文方法GoriM.andPucciA.ItemRank:arandom-walkbasedscoringalgorithmforrecommenderengines.InInternationalJointConferencesonArt......
  • 将 SAP Spartacus 作为 feature module 进行 Lazy Load 延迟加载时遇到的注入错误分析
    将SAPSpartacus作为featuremodule进行LazyLoad延迟加载时,遇到如下错误:ERRORError:Uncaught(inpromise):NullInjectorError:R3InjectorError(CatalogModu......
  • C++学习笔记《面向对象概述》
    《面向对象概述》1.面向过程的结构化编程:把数据和动作分开放置,把数据放入到动作当中。采用自顶向下的方法构建程序,包含顺序,选择和循环三种结构。按照程序执行的时序步骤来......