Linq与委托
using System;
using System.Linq;
using System.Reflection;
using Stuglxt_Models;
namespace ConsoleApp1
{
public delegate int MydeleGate(int a, int b);
class Program
{
static void Main(string[] args)
{
#region 委托与多播
//Student student = new Student();
//MydeleGate mydeleGate =(a,b)=> a+b;
//dynamic result = mydeleGate(5, 2);
//Console.WriteLine(result);
//mydeleGate += student.Add;
//result = mydeleGate==null? mydeleGate+=student.Sub:mydeleGate+=student.Add;
//result=result(1, 2);
//Console.WriteLine(result);
#endregion
#region 数组linq查询方法
//linq
//int[] nums = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
//var item = from num in nums where num % 2 == 0 orderby num descending select num;
//foreach (var i in item) {
// Console.WriteLine(i);
//}
#endregion
#region 字符串linq查询方法
//string[] nums = { "张**", "年*", "陈*", "刘*", "王*", "韩*", "吴*","年*" };
//var list = nums.Where(item => item.Length == 2).Select(item => item).GroupBy(item => item.Substring(0, 1));
//foreach (var item in list) {
// Console.WriteLine("-----------");
// Console.WriteLine("分组字段:{0}",item.Key);
// foreach (var k in item) {
// Console.WriteLine(k);
// }
//}
#endregion
#region linq高级查询方法
int[] nums = { , , , , , , , , , };
//var Count = nums.Count();//获取元素个数
//Console.WriteLine(Count);
int[] nums0 = { , , , , , , , , , };
//var list = nums.Skip(1).Take(3);//指定列跳过和选择指定项个数输
//var list = nums.SkipWhile(i => i % 3 != 0).TakeWhile(i => i % 2 != 0);//跳过符合条件的数列和选取符合条件的数列
var list = nums0.Distinct();//去重复
foreach (var i in list) {
Console.WriteLine(i);
}
#endregion
Console.ReadKey();
}
class Student
{
public int Add(int a, int b) => a + b;
public int Sub(int a, int b) => a - b;
}
}
}
我的平时练习代码
Linq与委托的更多相关文章
- 委托发展史(Linq操作符)
嗯~这篇就讲讲Linq吧! 之前讲过Lambda最后进化到了令人发指的地步: Func<string, int> returnLength; returnLength = text =&g ...
- C#基础知识简单梳理
本文是转发博友的总结,方便自己以后随时温习: 1.值类型和引用类型 1.1堆和栈 简单的说值类型存放在堆栈上面,引用类型的数据存放在托管堆上面(它的引用地址却存放在堆栈上面)! 栈:它是一个内存数组, ...
- 生产环境下实践DDD中的规约模式
最近的开发工作涉及到两个模块“任务”和“日周报”.关系是日周报消费任务,因为用户在写日周报的时候,需要按一定的规则筛选当前用户的任务,作为日周报的一部分提交.整个项目采用类似于Orchard那种平台加 ...
- 转载文章----C#基础概念
转载地址:http://www.cnblogs.com/zhouzhou-aspnet/articles/2591596.html 1.值类型和引用类型 1.1堆和栈 简单的说值类型存放在堆栈上面,引 ...
- solr主从复制
solr主从复制 最近的开发工作涉及到两个模块“任务”和“日周报”.关系是日周报消费任务,因为用户在写日周报的时候,需要按一定的规则筛选当前用户的任务,作为日周报的一部分提交.整个项目采用类似于Orc ...
- c#知识梳理
转:http://www.cnblogs.com/zhouzhou-aspnet/articles/2591596.html 本文是一个菜鸟所写,本文面向的人群就是像我这样的小菜鸟,工作一年也辛辛苦苦 ...
- ActionDescriptor 的认识
ActionDescriptor的作用是对Action方法的元数据的描述,通过ActionDescriptor我们可以获取到action方法的相关的名称,所属控制器,方法的参数列表,应用到方法上的特性 ...
- C#基础知识 (转)
https://www.cnblogs.com/zhouzhou-aspnet/articles/2591596.html(原文地址) 本文是一个菜鸟所写,本文面向的人群就是像我这样的小菜鸟,工作一年 ...
- Silverlight项目笔记1:UI控件与布局、MVVM、数据绑定、await/async、Linq查询、WCF RIA Services、序列化、委托与事件
最近从技术支持转到开发岗,做Silverlight部分的开发,用的Prism+MVVM,框架由同事搭好,目前做的主要是功能实现,用到了一些东西,侧重于如何使用,总结如下 1.UI控件与布局 常用的主要 ...
随机推荐
- Django 简单的验证码
创建一个 Django 项目:yanzhengma 和 应用 app01 修改 urls.py 文件 from django.contrib import admin from django.urls ...
- lua脚本之钉钉免密登录
nginx.conf worker_processes ; error_log logs/error.log; events { worker_connections ; } http { resol ...
- 从Sources构建nginx,编译安装nginx
从Sources构建nginx 使用configure命令配置构建,定义了系统的各个方面,包括允许nginx用于连接处理的方法,最后创建了一个Makefile. configure命令参数: --he ...
- Transformer模型---encoder
一.简介 论文链接:<Attention is all you need> 由google团队在2017年发表于NIPS,Transformer 是一种新的.基于 attention 机制 ...
- Graph Embedding:
https://blog.csdn.net/hy_jz/article/details/78877483 基于meta-path的异质网络Embedding-metapath2vec metapath ...
- git clean (11)
#delete untracked files git clean -f # delete untracked files and directories git clean -fd # -n opt ...
- 页面配置snmp设备有问题,有时候能收到测试团体名的信息,有时候收不到
现在走的是使用fabric远程连接zabbix服务器,这其中也会耗时间,代码中写的2s不返回数据就提示检查snmp信息失败,不合理, 目前df的server跟show在同一台机器,可以在本地直接调用, ...
- CSP-S2019游记 执枪的人,一定要做好被杀的觉悟。
啊,大概是人生中最镇定的三天了. 是了. Day0 教练超级巨,给了我们电话说出去要散养,有事别慌,打电话.身份证丢了别慌,打电话.火车误了别慌,打电话... 然后去了就路上颓颓颓.然后过去试机,打了 ...
- 动态规划 | 对输入进行hash处理的LIS 1045
把序列M处理为有序序列,并且M不存在的序列要在A中删除. 对A进行了处理之后,执行LIS的操作(O(N^2)复杂度).当然可以优化为对数复杂度的,不过pat不卡这个. LCS解法:动态规划 | 保留重 ...
- [LeetCode] 505. The Maze II 迷宫之二
There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolli ...