元素操作符仅返回一个元素。

一、Fitst操作符

First操作符将返回序列中的第一个元素。如果序列中不包含任何元素,则First<T>方法将引发异常。来看看First()方法的定义:

从定义中可以看出:First()方法共有两个重载。First<T>的有参重载方法中可以指定一个条件,操作将返回序列中满足此条件的第一个元素。从查询结果上看,source.First<T>(条件)方法与source.where(条件).First<T>是一样的,但是需要注意的是:First<T>(条件)操作将返回序列中满足此条件的第一个元素,这将会忽略后面的遍历操作,效率更高。请看下面的例子:

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ElementOperation
{
class Program
{
static void Main(string[] args)
{
// First
List<Product> listProduct = new List<Product>()
{
new Product(){Id=,CategoryId=, Name="C#高级编程第10版", Price=100.67,CreateTime=DateTime.Now},
new Product(){Id=,CategoryId=, Name="Redis开发和运维", Price=69.9,CreateTime=DateTime.Now.AddDays(-)},
new Product(){Id=,CategoryId=, Name="活着", Price=,CreateTime=DateTime.Now.AddMonths(-)},
new Product(){Id=,CategoryId=, Name="高等数学", Price=,CreateTime=DateTime.Now.AddMonths(-)},
new Product(){Id=,CategoryId=, Name="国家宝藏", Price=52.8,CreateTime=DateTime.Now.AddMonths(-)}
}; // 方法语法
var productExp = listProduct.First();
Console.WriteLine($"Id:{productExp.Id},CategoryId:{productExp.CategoryId},Name:{productExp.Name},Price:{productExp.Price},CreateTime:{productExp.CreateTime}");
// 查询表达式
var productFun = (from p in listProduct select p).First();
Console.WriteLine($"Id:{productFun.Id},CategoryId:{productFun.CategoryId},Name:{productFun.Name},Price:{productFun.Price},CreateTime:{productFun.CreateTime}");
// 根据委托进行刷选
// 查询CategoryId为1的集合的第一个元素
// 方法语法
var productDeleExp = listProduct.First(p => p.CategoryId.Equals());
Console.WriteLine($"Id:{productDeleExp.Id},CategoryId:{productDeleExp.CategoryId},Name:{productDeleExp.Name},Price:{productDeleExp.Price},CreateTime:{productDeleExp.CreateTime}");
// 查询表达式
var productDeleFun = (from p in listProduct where p.CategoryId.Equals() select p).First();
Console.WriteLine($"Id:{productDeleFun.Id},CategoryId:{productDeleFun.CategoryId},Name:{productDeleFun.Name},Price:{productDeleFun.Price},CreateTime:{productDeleFun.CreateTime}");
// 或者使用下面的查询表达式
var product = (from p in listProduct select p).First(z => z.CategoryId.Equals());
Console.WriteLine($"Id:{product.Id},CategoryId:{product.CategoryId},Name:{product.Name},Price:{product.Price},CreateTime:{product.CreateTime}");
Console.ReadKey();
}
}
}

结果:

注意:

1、如果序列中不包含任何元素,则First<T>方法将引发异常。看下面的例子:

 var pro = listProduct.First(p => p.CategoryId.Equals());
Console.WriteLine($"Id:{pro.Id},CategoryId:{pro.CategoryId},Name:{pro.Name},Price:{pro.Price},CreateTime:{pro.CreateTime}");

结果:

二、FirstOrDefault操作符

FirstOrDefault操作符也是返回序列中的第一个元素。与First()操作符不同的是:如果序列中不包含任何元素,FirstOrDefault则返回默认值,程序不会报错。来看看定义:

从定义中可以看出:FirstOrDefault和First操作符的重载方法一致。请看下面的例子:

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ElementOperation
{
class Program
{
static void Main(string[] args)
{
// First
List<Product> listProduct = new List<Product>()
{
new Product(){Id=,CategoryId=, Name="C#高级编程第10版", Price=100.67,CreateTime=DateTime.Now},
new Product(){Id=,CategoryId=, Name="Redis开发和运维", Price=69.9,CreateTime=DateTime.Now.AddDays(-)},
new Product(){Id=,CategoryId=, Name="活着", Price=,CreateTime=DateTime.Now.AddMonths(-)},
new Product(){Id=,CategoryId=, Name="高等数学", Price=,CreateTime=DateTime.Now.AddMonths(-)},
new Product(){Id=,CategoryId=, Name="国家宝藏", Price=52.8,CreateTime=DateTime.Now.AddMonths(-)}
}; // 方法语法
var productExp = listProduct.FirstOrDefault();
Console.WriteLine($"Id:{productExp.Id},CategoryId:{productExp.CategoryId},Name:{productExp.Name},Price:{productExp.Price},CreateTime:{productExp.CreateTime}");
// 查询表达式
var productFun = (from p in listProduct select p).FirstOrDefault();
Console.WriteLine($"Id:{productFun.Id},CategoryId:{productFun.CategoryId},Name:{productFun.Name},Price:{productFun.Price},CreateTime:{productFun.CreateTime}");
// 根据委托进行刷选
// 查询CategoryId为1的集合的第一个元素
// 方法语法
var productDeleExp = listProduct.FirstOrDefault(p => p.CategoryId.Equals());
Console.WriteLine($"Id:{productDeleExp.Id},CategoryId:{productDeleExp.CategoryId},Name:{productDeleExp.Name},Price:{productDeleExp.Price},CreateTime:{productDeleExp.CreateTime}");
// 查询表达式
var productDeleFun = (from p in listProduct where p.CategoryId.Equals() select p).FirstOrDefault();
Console.WriteLine($"Id:{productDeleFun.Id},CategoryId:{productDeleFun.CategoryId},Name:{productDeleFun.Name},Price:{productDeleFun.Price},CreateTime:{productDeleFun.CreateTime}");
// 或者使用下面的查询表达式
var product = (from p in listProduct select p).FirstOrDefault(z => z.CategoryId.Equals());
Console.WriteLine($"Id:{product.Id},CategoryId:{product.CategoryId},Name:{product.Name},Price:{product.Price},CreateTime:{product.CreateTime}");
Console.ReadKey();
}
}
}

结果:

注意:

与First()操作符不同的是:如果序列中不包含任何元素,FirstOrDefault则返回默认值,程序不会报错。看下面的例子:

 // 查询listProduct中CategoryId为4的集合的第一个元素
var pro = listProduct.FirstOrDefault(p => p.CategoryId.Equals());
Console.WriteLine($"Id:{pro.Id},CategoryId:{pro.CategoryId},Name:{pro.Name},Price:{pro.Price},CreateTime:{pro.CreateTime}");

结果:

从上面的截图中看出:如果序列中不包含任何元素,会自动用null进行填充。但是下面输出的时候要先判断查询结果是否为null。

三、Last操作符

Last方法将返回序列中的最后一个元素。看下面的例子:

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ElementOperation
{
class Program
{
static void Main(string[] args)
{
// First
List<Product> listProduct = new List<Product>()
{
new Product(){Id=,CategoryId=, Name="C#高级编程第10版", Price=100.67,CreateTime=DateTime.Now},
new Product(){Id=,CategoryId=, Name="Redis开发和运维", Price=69.9,CreateTime=DateTime.Now.AddDays(-)},
new Product(){Id=,CategoryId=, Name="活着", Price=,CreateTime=DateTime.Now.AddMonths(-)},
new Product(){Id=,CategoryId=, Name="高等数学", Price=,CreateTime=DateTime.Now.AddMonths(-)},
new Product(){Id=,CategoryId=, Name="国家宝藏", Price=52.8,CreateTime=DateTime.Now.AddMonths(-)}
}; // 方法语法
var productExp = listProduct.Last();
Console.WriteLine($"Id:{productExp.Id},CategoryId:{productExp.CategoryId},Name:{productExp.Name},Price:{productExp.Price},CreateTime:{productExp.CreateTime}");
// 查询表达式
var productFun = (from p in listProduct select p).Last();
Console.WriteLine($"Id:{productFun.Id},CategoryId:{productFun.CategoryId},Name:{productFun.Name},Price:{productFun.Price},CreateTime:{productFun.CreateTime}");
// 根据委托进行刷选
// 查询CategoryId为1的集合的第一个元素
// 方法语法
var productDeleExp = listProduct.Last(p => p.CategoryId.Equals());
Console.WriteLine($"Id:{productDeleExp.Id},CategoryId:{productDeleExp.CategoryId},Name:{productDeleExp.Name},Price:{productDeleExp.Price},CreateTime:{productDeleExp.CreateTime}");
// 查询表达式
var productDeleFun = (from p in listProduct where p.CategoryId.Equals() select p).Last();
Console.WriteLine($"Id:{productDeleFun.Id},CategoryId:{productDeleFun.CategoryId},Name:{productDeleFun.Name},Price:{productDeleFun.Price},CreateTime:{productDeleFun.CreateTime}");
// 或者使用下面的查询表达式
var product = (from p in listProduct select p).Last(z => z.CategoryId.Equals());
Console.WriteLine($"Id:{product.Id},CategoryId:{product.CategoryId},Name:{product.Name},Price:{product.Price},CreateTime:{product.CreateTime}");
Console.ReadKey();
}
}
}

结果:

注意:

Last操作符和First操作符一样,如果序列中不包含任何元素,则程序会直接报错。

四、LastOrDefault操作符

LastOrDefault操作符将返回序列中的最后一个元素;如果序列中不包含任何元素,则返回默认值。来看下面的例子:

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ElementOperation
{
class Program
{
static void Main(string[] args)
{
// First
List<Product> listProduct = new List<Product>()
{
new Product(){Id=,CategoryId=, Name="C#高级编程第10版", Price=100.67,CreateTime=DateTime.Now},
new Product(){Id=,CategoryId=, Name="Redis开发和运维", Price=69.9,CreateTime=DateTime.Now.AddDays(-)},
new Product(){Id=,CategoryId=, Name="活着", Price=,CreateTime=DateTime.Now.AddMonths(-)},
new Product(){Id=,CategoryId=, Name="高等数学", Price=,CreateTime=DateTime.Now.AddMonths(-)},
new Product(){Id=,CategoryId=, Name="国家宝藏", Price=52.8,CreateTime=DateTime.Now.AddMonths(-)}
}; // 方法语法
var productExp = listProduct.LastOrDefault();
Console.WriteLine($"Id:{productExp.Id},CategoryId:{productExp.CategoryId},Name:{productExp.Name},Price:{productExp.Price},CreateTime:{productExp.CreateTime}");
// 查询表达式
var productFun = (from p in listProduct select p).LastOrDefault();
Console.WriteLine($"Id:{productFun.Id},CategoryId:{productFun.CategoryId},Name:{productFun.Name},Price:{productFun.Price},CreateTime:{productFun.CreateTime}");
// 根据委托进行刷选
// 查询CategoryId为1的集合的第一个元素
// 方法语法
var productDeleExp = listProduct.LastOrDefault(p => p.CategoryId.Equals());
Console.WriteLine($"Id:{productDeleExp.Id},CategoryId:{productDeleExp.CategoryId},Name:{productDeleExp.Name},Price:{productDeleExp.Price},CreateTime:{productDeleExp.CreateTime}");
// 查询表达式
var productDeleFun = (from p in listProduct where p.CategoryId.Equals() select p).LastOrDefault();
Console.WriteLine($"Id:{productDeleFun.Id},CategoryId:{productDeleFun.CategoryId},Name:{productDeleFun.Name},Price:{productDeleFun.Price},CreateTime:{productDeleFun.CreateTime}");
// 或者使用下面的查询表达式
var product = (from p in listProduct select p).LastOrDefault(z => z.CategoryId.Equals());
Console.WriteLine($"Id:{product.Id},CategoryId:{product.CategoryId},Name:{product.Name},Price:{product.Price},CreateTime:{product.CreateTime}");
Console.ReadKey();
}
}
}

结果:

注意:

LastOrDefault和FirstOrDefault一样,如果序列中不包含任何元素,则使用null值进行填充返回值。

五、ElementAt操作符

ElementAt操作符返回序列中指定索引处的元素。来看下面的例子:

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ElementOperation
{
class Program
{
static void Main(string[] args)
{
// First
List<Product> listProduct = new List<Product>()
{
new Product(){Id=,CategoryId=, Name="C#高级编程第10版", Price=100.67,CreateTime=DateTime.Now},
new Product(){Id=,CategoryId=, Name="Redis开发和运维", Price=69.9,CreateTime=DateTime.Now.AddDays(-)},
new Product(){Id=,CategoryId=, Name="活着", Price=,CreateTime=DateTime.Now.AddMonths(-)},
new Product(){Id=,CategoryId=, Name="高等数学", Price=,CreateTime=DateTime.Now.AddMonths(-)},
new Product(){Id=,CategoryId=, Name="国家宝藏", Price=52.8,CreateTime=DateTime.Now.AddMonths(-)}
}; // 方法语法
// 查询集合中索引为3的元素 即Id=4
var productExp = listProduct.ElementAt();
Console.WriteLine($"Id:{productExp.Id},CategoryId:{productExp.CategoryId},Name:{productExp.Name},Price:{productExp.Price},CreateTime:{productExp.CreateTime}");
// 查询表达式
// 查询集合中索引为2的元素 即Id=3
var productFun = (from p in listProduct select p).ElementAt();
Console.WriteLine($"Id:{productFun.Id},CategoryId:{productFun.CategoryId},Name:{productFun.Name},Price:{productFun.Price},CreateTime:{productFun.CreateTime}");
Console.ReadKey();
}
}
}

结果:

注意:

ElementAt()的参数值必须是集合中存在的索引,否则程序会直接报错,看下面的例子:

 // 查询集合中索引为7的元素
var product = listProduct.ElementAt();

结果:

六:ElementAtOrDefault操作符

ElementAtOrDefault方法将返回序列中指定索引处的元素;如果索引超出范围,则返回默认值。看下面的例子:

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ElementOperation
{
class Program
{
static void Main(string[] args)
{
// First
List<Product> listProduct = new List<Product>()
{
new Product(){Id=,CategoryId=, Name="C#高级编程第10版", Price=100.67,CreateTime=DateTime.Now},
new Product(){Id=,CategoryId=, Name="Redis开发和运维", Price=69.9,CreateTime=DateTime.Now.AddDays(-)},
new Product(){Id=,CategoryId=, Name="活着", Price=,CreateTime=DateTime.Now.AddMonths(-)},
new Product(){Id=,CategoryId=, Name="高等数学", Price=,CreateTime=DateTime.Now.AddMonths(-)},
new Product(){Id=,CategoryId=, Name="国家宝藏", Price=52.8,CreateTime=DateTime.Now.AddMonths(-)}
}; // 方法语法
// 查询集合中索引为3的元素 即Id=4
var productExp = listProduct.ElementAtOrDefault();
Console.WriteLine($"Id:{productExp.Id},CategoryId:{productExp.CategoryId},Name:{productExp.Name},Price:{productExp.Price},CreateTime:{productExp.CreateTime}");
// 查询表达式
// 查询集合中索引为2的元素 即Id=3
var productFun = (from p in listProduct select p).ElementAtOrDefault();
Console.WriteLine($"Id:{productFun.Id},CategoryId:{productFun.CategoryId},Name:{productFun.Name},Price:{productFun.Price},CreateTime:{productFun.CreateTime}");
Console.ReadKey();
}
}
}

结果:

注意:

如果索引超出范围,则返回默认值。看下面的例子:

从上面的截图中看出:如果索引超出范围,则用null填充返回值。

七、Single操作符

Single操作符将从一个序列中返回单个元素,如果该序列包含多个元素,或者没有元素数为0,则会引发异常。看看定义:

从定义中能够看出:Single操作符共有两个重载的方法。无参的方法重载将从一个序列中返回单个元素,如果该序列包含多个元素,或者没有元素数为0,则会引发异常。参数为委托的方法重载将返回满足委托条件的单个元素。看下面的例子:

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ElementOperation
{
class Program
{
static void Main(string[] args)
{ List<Product> listProduct = new List<Product>()
{
new Product(){Id=,CategoryId=, Name="C#高级编程第10版", Price=100.67,CreateTime=DateTime.Now}
}; // 方法语法
var productExp = listProduct.Single();
Console.WriteLine($"Id:{productExp.Id},CategoryId:{productExp.CategoryId},Name:{productExp.Name},Price:{productExp.Price},CreateTime:{productExp.CreateTime}");
// 查询表达式
var productFun = (from p in listProduct select p).Single();
Console.WriteLine($"Id:{productFun.Id},CategoryId:{productFun.CategoryId},Name:{productFun.Name},Price:{productFun.Price},CreateTime:{productFun.CreateTime}");
// 根据委托进行刷选
// 查询CategoryId为1的集合的第一个元素
// 方法语法
var productDeleExp = listProduct.Single(p => p.CategoryId.Equals());
Console.WriteLine($"Id:{productDeleExp.Id},CategoryId:{productDeleExp.CategoryId},Name:{productDeleExp.Name},Price:{productDeleExp.Price},CreateTime:{productDeleExp.CreateTime}");
// 查询表达式
var productDeleFun = (from p in listProduct where p.CategoryId.Equals() select p).Single();
Console.WriteLine($"Id:{productDeleFun.Id},CategoryId:{productDeleFun.CategoryId},Name:{productDeleFun.Name},Price:{productDeleFun.Price},CreateTime:{productDeleFun.CreateTime}");
// 或者使用下面的查询表达式
var product = (from p in listProduct select p).Single(z => z.CategoryId.Equals());
Console.WriteLine($"Id:{product.Id},CategoryId:{product.CategoryId},Name:{product.Name},Price:{product.Price},CreateTime:{product.CreateTime}");
Console.ReadKey();
}
}
}

结果:

注意:

如果序列包含多个元素,或者序列元素数为0,则会引发异常。看下面的例子。

1、序列包含多个元素

修改ListProduct为包含多个元素的集合:

 // 1、序列包含多个元素
List<Product> listProduct = new List<Product>()
{
new Product(){Id=,CategoryId=, Name="C#高级编程第10版", Price=100.67,CreateTime=DateTime.Now},
new Product(){Id=,CategoryId=, Name="Redis开发和运维", Price=69.9,CreateTime=DateTime.Now.AddDays(-)},
};
var productExp = listProduct.Single();

结果:

2、序列中不包含任何元素。

 // 2、序列不包含任何元素
List<Product> listProduct = new List<Product>();
var productExp = listProduct.Single();

结果:

八、SingleOrDefault操作符

SingleOrDefault方操作符将从一个序列中返回单个元素。如果元素数为0,则返回默认值。看定义:

从定义中可以看出:SingleOrDefault的定义和Single的定义一致。看下面的例子:

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ElementOperation
{
class Program
{
static void Main(string[] args)
{
List<Product> listProduct = new List<Product>()
{
new Product(){Id=,CategoryId=, Name="C#高级编程第10版", Price=100.67,CreateTime=DateTime.Now}
}; // 方法语法
var productExp = listProduct.SingleOrDefault();
Console.WriteLine($"Id:{productExp.Id},CategoryId:{productExp.CategoryId},Name:{productExp.Name},Price:{productExp.Price},CreateTime:{productExp.CreateTime}");
// 查询表达式
var productFun = (from p in listProduct select p).Single();
Console.WriteLine($"Id:{productFun.Id},CategoryId:{productFun.CategoryId},Name:{productFun.Name},Price:{productFun.Price},CreateTime:{productFun.CreateTime}");
// 根据委托进行刷选
// 查询CategoryId为1的集合的第一个元素
// 方法语法
var productDeleExp = listProduct.Single(p => p.CategoryId.Equals());
Console.WriteLine($"Id:{productDeleExp.Id},CategoryId:{productDeleExp.CategoryId},Name:{productDeleExp.Name},Price:{productDeleExp.Price},CreateTime:{productDeleExp.CreateTime}");
// 查询表达式
var productDeleFun = (from p in listProduct where p.CategoryId.Equals() select p).Single();
Console.WriteLine($"Id:{productDeleFun.Id},CategoryId:{productDeleFun.CategoryId},Name:{productDeleFun.Name},Price:{productDeleFun.Price},CreateTime:{productDeleFun.CreateTime}");
// 或者使用下面的查询表达式
var product = (from p in listProduct select p).Single(z => z.CategoryId.Equals());
Console.WriteLine($"Id:{product.Id},CategoryId:{product.CategoryId},Name:{product.Name},Price:{product.Price},CreateTime:{product.CreateTime}");
Console.ReadKey();
}
}
}

结果:

注意:

如果序列包含多个元素或者不包含任何元素,则用null值填充返回值。看下面例子:

1、序列包含多个元素

 // 1、序列包含多个元素
List<Product> listProduct = new List<Product>()
{
new Product(){Id=,CategoryId=, Name="C#高级编程第10版", Price=100.67,CreateTime=DateTime.Now},
new Product(){Id=,CategoryId=, Name="Redis开发和运维", Price=69.9,CreateTime=DateTime.Now.AddDays(-)},
};
var productExp = listProduct.SingleOrDefault();

结果:

2、序列不包含任何元素

 // 2、序列不包含任何元素
List<Product> listProduct = new List<Product>();
var productExp = listProduct.SingleOrDefault();

结果:

linq操作符:元素操作符的更多相关文章

  1. LINQ标准查询操作符详解(转)

     一. 关于LINQ       LINQ 英文全称是“Language-Integrated Query”,中文为“语言集成查询”,它是微软首席架构师.Delphi 之父和C# 之父——Anders ...

  2. Linq 标准查询操作符三

    本文介绍了LINQ标准查询操作符.没有这些操作符,LINQ就不会存在.本文为理解这些操作符的功能提供了很好的基础.了解它们将会很有帮助,因为LINQ的各种Provider都是基于这些操作符来完成各自丰 ...

  3. LINQ 标准查询操作符

    本文介绍了LINQ标准查询操作符.没有这些操作符,LINQ就不会存在.本文为理解这些操作符的功能提供了很好的基础.了解它们将会很有帮助,因为LINQ的各种Provider都是基于这些操作符来完成各自丰 ...

  4. LINQ标准查询操作符(四) —AsEnumerable,Cast,OfType,ToArray,ToDictionary,ToList,ToLookup,First,Last,ElementAt

    十.转换操作符 转换操作符是用来实现将输入对象的类型转变为序列的功能.名称以“As”开头的转换方法可更改源集合的静态类型但不枚举(延迟加载)此源集合.名称以“To”开头的方法可枚举(即时加载)源集合并 ...

  5. LINQ系列:Linq to Object元素操作符

    元素操作符从一个序列返回单个指定的元素. 1. DefaultIfEmpty DefaultIfEmpty操作符将一个空集合替换为包含默认的单个值的集合.在返回序列为空且又需要返回一些对象时,可以通过 ...

  6. LINQ标准查询操作符(三)——Aggregate、Average、Distinct、Except、Intersect、Union、Empty、DefaultIfEmpty、Range、Repeat

    七.聚合操作符 聚合函数将在序列上执行特定的计算,并返回单个值,如计算给定序列平均值.最大值等.共有7种LINQ聚合查询操作符:Aggregate.Average.Count.LongCount.Ma ...

  7. Linq标准查询操作符

     Linq的出现让代码简洁了不少.之前在项目中基本都在使用它,但是没有完整的整理过,今天借这个周末,将其进行整理,方便后期对其的使用.Linq的操作可以分为聚合,连接,转换,元素操作符,相等操作,生成 ...

  8. Linq学习之操作符

    一.环境搭建 下面将逐步搭建我们学习的环境,这个环境不仅仅是这次需要使用,以后的教程一样需要使用这个环境.所以请大家务必按照 搭建这里的环境否则会影响你后面的学习. 我们用到的几张表 通知消息表: 用 ...

  9. LINQ标准查询操作符(一)——select、SelectMany、Where、OrderBy、OrderByDescending、ThenBy、ThenByDescending和Reverse

    一.投影操作符 1. Select Select操作符对单个序列或集合中的值进行投影.下面的示例中使用select从序列中返回Employee表的所有列: //查询语法 var query = fro ...

随机推荐

  1. iOS基础总结

    面试题预览: 1.KVO实现原理? 2.说说你理解的埋点? 3.消息转发机制原理? 4.说说你理解weak属性? 5.假如Controller太臃肿,如何优化? 6.项目中网络层如何做安全处理? 7. ...

  2. 《Android源代码设计模式解析》读书笔记——Android中你应该知道的设计模式

    断断续续的,<Android源代码设计模式解析>也看了一遍.书中提到了非常多的设计模式.可是有部分在开发中见到的几率非常小,所以掌握不了也没有太大影响. 我认为这本书的最大价值有两点,一个 ...

  3. Fluent UDF【7】:解释型UDF

    UDF宏有两种方式可以被Fluent所接受:编译和解释.其中有一些宏既可以被解释也可以被编译,而一些宏则只能被解释.有一些场合只接受编译后的UDF(如动网格中的一些宏),而有些场合既可以接受编译的UD ...

  4. DIOCP开源项目-利用队列+0MQ+多进程逻辑处理,搭建稳定,高效,分布式的服务端

    最近头脑里面一直在想怎么样让能让大家基于DIOCP上写出稳定的服务端程序.很多朋友问我,你DIOCP稳定吗,我可以用他来做三层服务器吗? 当时我是这样回答的,我只能保证DIOCP底层通信的稳定. 说实 ...

  5. Excel2013 破解(编辑工作表受保护)密码

    在日常工作中,大家有时会遇到过这样的情况:使用Excel编制的报表.表格.程序等,在单元格中设置了公式.函数等,为了防止其他人修改您的设置或者防止您自己无意中修改,您可能会使用Excel的工作表保护功 ...

  6. Lintcode:Longest Common Subsequence 解题报告

    Longest Common Subsequence 原题链接:http://lintcode.com/zh-cn/problem/longest-common-subsequence/ Given ...

  7. NSOperation和NSOperationQueue的一些基本操作

    当初学习多线程这一块的时候,时间比较匆忙,没有细细考虑,而今重新学一次,算是复习和总结吧. #import "ViewController.h" @interface ViewCo ...

  8. Android 自动化测试

    Python +Android +uiautomator test  在init中定义的方法 uiautomator     该模块是android的一个python包装uiautomator测试框架 ...

  9. C#学习笔记(5)——大项目查找

    说明(2017-5-27 16:34:39): 1. 注意事项: (0)设计窗体,添加一个dgv,添加5个列名,修改名字和绑定数据. (1)添加引用,system.data.sqlclient (2) ...

  10. jQuery弹性展开收缩菜单插件gooey.js

    分享一款基于jQuery弹性展开收缩菜单插件gooey.js.这是一款基于gooey.js插件实现的弹性菜单特效代码.效果图如下: 在线预览   源码下载 实现的代码. html代码: <hea ...