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与委托的更多相关文章

  1. 委托发展史(Linq操作符)

    嗯~这篇就讲讲Linq吧! 之前讲过Lambda最后进化到了令人发指的地步: Func<string, int> returnLength; returnLength = text =&g ...

  2. C#基础知识简单梳理

    本文是转发博友的总结,方便自己以后随时温习: 1.值类型和引用类型 1.1堆和栈 简单的说值类型存放在堆栈上面,引用类型的数据存放在托管堆上面(它的引用地址却存放在堆栈上面)! 栈:它是一个内存数组, ...

  3. 生产环境下实践DDD中的规约模式

    最近的开发工作涉及到两个模块“任务”和“日周报”.关系是日周报消费任务,因为用户在写日周报的时候,需要按一定的规则筛选当前用户的任务,作为日周报的一部分提交.整个项目采用类似于Orchard那种平台加 ...

  4. 转载文章----C#基础概念

    转载地址:http://www.cnblogs.com/zhouzhou-aspnet/articles/2591596.html 1.值类型和引用类型 1.1堆和栈 简单的说值类型存放在堆栈上面,引 ...

  5. solr主从复制

    solr主从复制 最近的开发工作涉及到两个模块“任务”和“日周报”.关系是日周报消费任务,因为用户在写日周报的时候,需要按一定的规则筛选当前用户的任务,作为日周报的一部分提交.整个项目采用类似于Orc ...

  6. c#知识梳理

    转:http://www.cnblogs.com/zhouzhou-aspnet/articles/2591596.html 本文是一个菜鸟所写,本文面向的人群就是像我这样的小菜鸟,工作一年也辛辛苦苦 ...

  7. ActionDescriptor 的认识

    ActionDescriptor的作用是对Action方法的元数据的描述,通过ActionDescriptor我们可以获取到action方法的相关的名称,所属控制器,方法的参数列表,应用到方法上的特性 ...

  8. C#基础知识 (转)

    https://www.cnblogs.com/zhouzhou-aspnet/articles/2591596.html(原文地址) 本文是一个菜鸟所写,本文面向的人群就是像我这样的小菜鸟,工作一年 ...

  9. Silverlight项目笔记1:UI控件与布局、MVVM、数据绑定、await/async、Linq查询、WCF RIA Services、序列化、委托与事件

    最近从技术支持转到开发岗,做Silverlight部分的开发,用的Prism+MVVM,框架由同事搭好,目前做的主要是功能实现,用到了一些东西,侧重于如何使用,总结如下 1.UI控件与布局 常用的主要 ...

随机推荐

  1. CentOs 7.*中配置安装phpMyAdmin的完整步骤记录

    phpMyAdmin是一个以PHP为基础,以Web-Base方式架构在网站主机上的MySQL的资料库管理工具.下面这篇文章主要给大家介绍了关于CentOs 7.*中配置安装phpMyAdmin的相关资 ...

  2. MarkdownPad 2破解

    MarkdownPad 2 是一款较不错的Markdown编辑器,可快速将文本转换为美观的HTML/XHTML的网页格式代码,且操作方便,用户可以通过键盘快捷键和工具栏按钮来使用或者移除Markdow ...

  3. Maven 拥有三套相互独立的生命周期:clean、default、site

    table th:nth-of-type(1) { width: 70px; } table th:nth-of-type(2) { width: 100px; } 生命周期 目的 包含的阶段 cle ...

  4. 【Spring Data JPA篇】项目环境搭建(一)

    项目环境: spring4.1.6 hibernate4.3.11 spring-data-jpa1.9.0 1. 创建一个Java Project,将jar导入到lib目录下 #spring spr ...

  5. VIJOS-P1201 高低位交换

    洛谷 P1100 高低位交换 https://www.luogu.org/problemnew/show/P1100 JDOJ 1349: VIJOS-P1201 高低位交换 https://neoo ...

  6. JDOJ 1152 是否是素数

    1152: 是否是素数 https://neooj.com:8082/oldoj/problem.php?id=1152 题目描述 写一个判断素数的函数,在主函数输入一个整数,输出是否是素数的消息. ...

  7. e.preventDefault()

    定义和用法 取消事件的默认动作. 语法 event.preventDefault() 说明 该方法将通知 Web 浏览器不要执行与事件关联的默认动作(如果存在这样的动作).例如,如果 type 属性是 ...

  8. workerman docker 运行试用

    看到别人项目使用了workerman 作为webserver ,看了下介绍发现此框架还是挺强大的,比较喜欢使用 docker运行软件,所以基于php 7.3 的基础镜像简单使用下 环境准备 项目使用了 ...

  9. github新建本地仓库并将代码提交到远程仓库

    方式一: 在github上新建好仓库:gitTest 使用命令git clone git@github.com:yourgithubID/gitTest.git,克隆到本地相应的位置 将要上传的工程代 ...

  10. js对url进行编码的方法(encodeURI和 encodeURICompoent())

    encodeURI(): 对整个URL进行编码,对应的解码方式:decodeURI() encodeURIComponent() : 对查询字符串进行编码,对应的解码方式:decodeURICompo ...