没有合适的资源?快使用搜索试试~ 我知道了~
Functional Programming With C# 7.1
需积分: 0 2 下载量 148 浏览量
2019-01-25
00:07:22
上传
评论 1
收藏 357KB PDF 举报
温馨提示
试读
8页
Progress Telerik出的C#函数式编程小抄。一共8页。简明扼要。
资源详情
资源评论
资源推荐
1
public class Rectangle
{
public int Length { get; set; }
public int Height { get; set; }
public void Grow(int length, int height)
{
Length += length;
Height += height;
}
}
Rectangle r = new Rectangle();
r.Length = 5;
r.Height = 10;
r.Grow(10, 10);
// r.Length is 15, r.Height is 20,
// same instance of r
Functional Programming
With C# 7.1
CHEAT SHEET
Functional programming is a style that treats computation as the evaluation of
mathematical functions and avoids changing-state and mutable data.
Immutable Types
An object whose state cannot be modified after it is created, lowering the risk of side-effects.
https://dotnetfiddle.net/K928pP
public class ImmutableRectangle
{
int Length { get; }
int Height { get; }
public ImmutableRectangle(int length,
int height)
{
Length = length;
Height = height;
}
public ImmutableRectangle Grow(int length,
int height) =>
new ImmutableRectangle(Length + length,
Height + height);
}
ImmutableRectangle r = new
ImmutableRectangle(5, 10);
r = r.Grow(10, 10);
// r.Length is 15, r.Height is 20,
// is a new instance of r
Mutable
Immutable
© 2017 Progress. All Rights Reserved.
freevoice
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- apk.tw_LineLite_v8a_v.2.17.1_sign.apk
- Elasticsearch实战:构建高效搜索系统的秘诀.zip
- HTML+CSS+JS网页设计:从入门到精通.zip
- 数据库课程设计:从理论到实践的全面指南.zip
- Python闭包:深入理解与应用场景解析.zip
- Win64OpenSSL-3-3-0.exe
- 课高分程设计-基于C++实现的民航飞行与地图简易管理系统-南京航空航天大学
- 航天器遥测数据故障检测系统python源码+文档说明+数据库(课程设计)
- 北京航空航天大学操作系统课设+ppt+实验报告
- 基于Vue+Echarts实现风力发电机中传感器的数据展示监控可视化系统+源代码+文档说明(高分课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0