摘要: let语句用于在Linq表达式中存储子表达式的计算结果。可以在后续的where子句中使用。例子:创建控制台应用程序Demo_letclass Program { static void Main(string[] args) { // 填充数据 List<PersonInfo> pList = new List<PersonInfo>() { new PersonInfo{ Name="周瑜", Country="吴", Official="都督", Salary=... 阅读全文
posted @ 2012-02-27 07:46 金丝猴 阅读(515) 评论(0) 推荐(0) 编辑
摘要: into 子句作为一个临时标识符,用于group,select,join子句中例子:一、创建控制台引用程序Demo_intoclass Program { static void Main(string[] args) { // 填充数据 PersonInfo 为实体类,代码见前面,这里就不赘述了。 List<PersonInfo> pList = new List<PersonInfo>() { new PersonInfo{ Name="周瑜", Country... 阅读全文
posted @ 2012-02-26 22:46 金丝猴 阅读(313) 评论(0) 推荐(0) 编辑
摘要: Linq中的查询语句要以from开始,以select或者是group来结束,返回结果集。group用来返回分组后的结果。group返回的 IGrouping<out TKey, out TElement> 类型的数据。TKey为每一组的键,TElement为每一组中是数据项。例子如下:一、首先创建控制台应用程序:DemoGroup_1class Program { static void Main(string[] args) { // 填充数据 List<PersonInfo> pList = new List<P... 阅读全文
posted @ 2012-02-26 22:00 金丝猴 阅读(361) 评论(0) 推荐(0) 编辑
摘要: Linq表达式的查询结果,是通过select得到的。select可以 进行数据转化工作,得到你想要的数据结果。一、创建控制台应用程序DemoSelect_1二、添加类 PersonInfo.csView Code /// <summary> /// 人物类 /// </summary> public class PersonInfo { /// <summary> /// 姓名 /// </summary> public string Name { get; set; } /// <summary> ... 阅读全文
posted @ 2012-02-18 19:12 金丝猴 阅读(296) 评论(0) 推荐(1) 编辑
摘要: Linq中的where主要用于对数据源的筛选。where可以有一个或者多个。一、创建控制台应用程序:DemoWhere_1二、添加自定义类:PersonInfo.csView Code /// <summary> /// 人物类 /// </summary> public class PersonInfo { /// <summary> /// 姓名 /// </summary> public string Name { get; set; } /// <summary> /// 国家 ... 阅读全文
posted @ 2012-02-18 18:07 金丝猴 阅读(452) 评论(0) 推荐(0) 编辑
摘要: from 语法要写一个Linq表达式必须要以from开头。不说废话,先看例子:一、简单的from查询1.首先,建立一个控制台应用程序名字为:DemoFrom_1 注意引入System.Core2.在Program.cs 输入以下语句View Code class Program { static void Main(string[] args) { // 定义数据源 // string 是实现了IEnumerable接口的,所以可以使用用Linq查询 string[] values = { "... 阅读全文
posted @ 2012-02-18 16:44 金丝猴 阅读(380) 评论(0) 推荐(1) 编辑
摘要: Route能做什么?ASP.NET 路由使我们在浏览器中看到的URL地址,映射到的页面并不一定是程序中真正存在的物理文件。这样有助于我们保护物理页面。那怎样使用路由呢?ASP.NET提供了RouteTable类来进行存储应用程序的URL路由。今天做了个粗略的了解,只是了解。。1.建立一个Web站点。(如果没有Global.asax文件,请添加)2.添加路由项protected void Application_Start(object sender, EventArgs e) { RouteTable.Routes.Add("R_1", new Route(... 阅读全文
posted @ 2012-01-30 16:48 金丝猴 阅读(12211) 评论(3) 推荐(1) 编辑
摘要: 在上一节中,我们讲解了线程池的基本应用。但是,我们如何给每个线程提供参数呢 ?因为每个线程执行所要执行的任务中,需要处理的参数也许不同。让我们来了解一下ThreadPool.QueueUserWorkItem方法。首先,看两个方法的签名:1.public static bool QueueUserWorkItem(WaitCallback callBack)方法// // 摘要: // 将方法排入队列以便执行。此方法在有线程池线程变得可用时执行。 // // 参数: // callBack: // ... 阅读全文
posted @ 2012-01-16 11:36 金丝猴 阅读(509) 评论(0) 推荐(0) 编辑
摘要: 线程Thread为我们同时处理多个任务提供了便利。但是问题又来了。当遇到以下问题时:1.当程序有不确定的多个小的任务时,我们无法事先确定要定义多少个Thread。2.当有新任务执行时,希望线程能够相应执行;当线程完成自己的任务时,能够释放相关资源并且线程数量进行相关减少。(换句话说,能够更加智能的控制线程数量)。其实,不必担心,已经有了解决方法。即使用ThreadPool类。先贴一个简单的例子:View Code using System;using System.Collections.Generic;using System.Text;using System.Threading;name 阅读全文
posted @ 2012-01-16 11:02 金丝猴 阅读(1439) 评论(0) 推荐(1) 编辑
摘要: 线程的优先级设置或者获得当前线程的优先级:using System;using System.Collections.Generic;using System.Text;using System.Threading;namespace ThreadTest{ class Program { static void Main(string[] args) { // 线程调度 Thread t5 = new Thread(ThreadMethed); // 获取一个值,该... 阅读全文
posted @ 2012-01-15 23:52 金丝猴 阅读(248) 评论(0) 推荐(1) 编辑