2013年12月10日

Lambda(2)

摘要: Lambda表达式是匿名方法的超集,处理匿名方法有的功能外,还有其他的功能:1.能够推测出参数的类型,无需显示声明2.支持语句块和表达式作为方法体Lambda表达式的书写方式:Lambda表达式有两种:语句Lambda和表达式Lambda例如:var re=>re+1 ---表达式Lambdavar re=>{return re+1;}---语句Lambda语句Lambda的操作符右边有一个{},其他的和表达式Lambda没什么区别 阅读全文

posted @ 2013-12-10 11:51 谭一丹 阅读(211) 评论(0) 推荐(0)

Linq中延迟查询和立即查询

摘要: //立即查询 public static void NowExecute() { var results = new int[]{5,4,3,2,1,6,7,8,9,0 }; int i = 0; var res = (from re in results select ++i).ToList();//立即查询,此时,i=10,res={1,2,3,4,5,6,7,8,9,10} foreach (var p in res) { Console.WriteLine("{0},{1}",i,p); } }单步调试结果:执行F10从调试结果可以看出,ToList后变为立即查询, 阅读全文

posted @ 2013-12-10 11:32 谭一丹 阅读(355) 评论(0) 推荐(0)

2013年12月9日

Linq--扩展方法

摘要: 如果现在有一个这样的需求,求筛选出来的大于20MB的进程的和,常用的方法是写一个静态方法传进去一个ProcessData列表比如:public static Int64 TotalMemory( IEnumerable process) { Int64 result = 0; foreach(var pro in process) { result +=pro.Memory; } return result; }如果现在还有一个需求:将筛选出来的结果用MB表示比如:Public static Int64 ByteToMegaByte(Int64 bytes){ return bytes/102 阅读全文

posted @ 2013-12-09 15:27 谭一丹 阅读(196) 评论(0) 推荐(0)

2013年12月7日

Lambda

摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace LinqDemo{ public class ProcessData { public int id { get; set; } public string Name { get; set; } public Int64 Memory { get; set; } }}using System;using System.Collections.Generic;using System.Linq;using Syst 阅读全文

posted @ 2013-12-07 17:42 谭一丹 阅读(362) 评论(0) 推荐(0)

dotNet中初始化器的使用

摘要: dotNet中初始化器的使用2013年12月7日13:27有两类初始化器:对象初始化器和集合初始化器比如现在有一个User类:Public class User{ public int id{get;set;} public string Name{get;set;} public int Age{get;set;}}对象初始化器:Var user=new User{id=1,Name="danche",Age=23}"传统"的方法:User user=new User();user.id=1;user.Name="danche";u 阅读全文

posted @ 2013-12-07 15:12 谭一丹 阅读(188) 评论(0) 推荐(0)

2013年12月5日

JQuery解析JSon

摘要: JsonCreatet.ashx页面JSonAnalysis.aspx测试页面一般处理程序中使用Newtonsoft.Json来序列化json页面使用Jquery 来解析Json数据Jquery.getJSON(url,[data][callback])getJSON有三个参数:url,请求的地址 data,传递的参数 callback,载入成功后回调函数。很有必要说一说each函数:jQuery.each(obj,fn,arg)该方法有三个参数:进行操作的对象obj,进行操作的函数fn,函数的参数args。让我们根据ojb对象进行讨论: 1.obj对象是数组each方法会对数组中子元素的逐个 阅读全文

posted @ 2013-12-05 11:48 谭一丹 阅读(310) 评论(0) 推荐(0)

2013年12月4日

系统中使用frameset和Iframe刷新页面session失效

摘要: 问题:Asp.net中每次刷新页面,session中保存的只就丢失原因: 1.有些杀毒软件会去扫描web.config文件 2.程序内部有让session丢失的代码,或服务器内存不足 3.程序有框架页面和跨域情况解决办法:1.使杀毒软件屏蔽扫描web.config文件2.检查代码使用有session.Abandon()只类的东东3.启用ASP.NET状态服务找到System.web节点下的sessionState节点修改为:,保存到session中的对象除了基本数据类型外都必须序列化。比如,保存了一个User实体[Serializable]public class User{ public i 阅读全文

posted @ 2013-12-04 17:45 谭一丹 阅读(464) 评论(0) 推荐(0)

Linq To Xml

摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace LinqDemo{ public class Book { public string Title; public string Author; public DateTime Year; public Book(string author, string title, DateTime year) { Title = title; Author = author; Year = year; } }}using 阅读全文

posted @ 2013-12-04 16:59 谭一丹 阅读(742) 评论(0) 推荐(0)

Json(2)-DataContractJsonSerializer

摘要: public static void DataContractSerializeDemo() { User user = new User { UserID = 1, UserName = "单车", Salary = 1000, CreateTime = DateTime.Now.AddYears(-2), Birthday = DateTime.Now.AddYears(-2), Urls = new List { "http://zhoufoxcn.blog.51cto.com", "http://blog.csdn.net/zhoufo 阅读全文

posted @ 2013-12-04 09:26 谭一丹 阅读(372) 评论(0) 推荐(0)

2013年12月3日

Linq To Json

摘要: 代码:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Runtime.Serialization;using Newtonsoft.Json;using Newtonsoft.Json.Converters;using System.Web.Script.Serialization;namespace JsonDemo{ [DataContract] public class User { [DataMember] public int UserID { 阅读全文

posted @ 2013-12-03 17:24 谭一丹 阅读(225) 评论(0) 推荐(0)

导航