随笔分类 - asp.net
该文被密码保护。
摘要:调用: var result = DateHelper.GetWeekOfDay(new DateTime(2016, 04, 04), new DateTime(2016, 04, 25)); 输出:3
阅读全文
摘要:调用:IntToDateTime(1458637638); 输出:2016/3/22 17:7:18 调用: DateTimeToInt(DateTime.Now); 输出:1458638060
阅读全文
摘要:指定JavaScriptSerializer不序列化公共属性或公共字段。无法继承此类。命名空间:System.Web.Script.Serialization程序集:System.Web.Extensions(在 System.Web.Extensions.dll 中)publicclassPers...
阅读全文
摘要:DictionaryobjDictionary=newDictionary();objDictionary.Add(1,"张三");objDictionary.Add(2,"李四");objDictionary.Add(3,"王二麻子");objDictionary.Add(4,"小淘气...
阅读全文
摘要:引入System.Runtime.Serialization.Json命名空间使用 DataContractJsonSerializer类实现序列化序列化类:PeopleCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> public class People { public int Id { get; set; } public string Name { get; set...
阅读全文
摘要:public static class ObjectExtension { public static T Convert<T>(this object target) { T result = default(T); if (target != null) { result = (T)System.Convert.ChangeType(target, typeof(T), CultureInfo.InvariantCulture); } ...
阅读全文
摘要:原贴地址:http://www.soaspx.com/dotnet/csharp/csharp_20110506_7607.htmlCultureInfo简述CultureInfo类位于System.Globalization命名空间内,这个类和这个命名空间许多人都不了解也认为不需要太多了解,实际上,你写的程序中会经常间接得使用这些类。简单的说:当进行数字,日期时间,字符串匹配时,都会进行CultureInfo的处理,也就是不同的CultureInfo下,这些操作的结果可能会不一样。这里要介绍一下非常容易被忽视的InvariantCulture。通过示例了解InvariantCulture前面
阅读全文
摘要:原贴地址:http://www.cnblogs.com/zhongweiv/archive/2011/11/11/IEqualityComparer.html写这个源于CSDN一位网友的提问题目:下列数据放在一个List中,当ID和Name都相同时,去掉重复数据ID Name 1 张三 1 李三 1 小伟 1 李三 2 李四 2 李武------------------------------------------------------------------------------------------------------------解决这个问题,方法很多,最开始想到的就Enum.
阅读全文
摘要:usingSystem;usingSystem.Drawing;usingSystem.Drawing.Drawing2D;usingSystem.Drawing.Imaging;usingSystem.IO;usingSystem.Text;usingSystem.Web;namespaceWanJia.CommonUtility{///<summary>///VerifyCode///</summary>publicclassVerifyCode{#regionPrivateField&PublicProperty//随机种子privateRandomobj
阅读全文
摘要:大家都知道SQL语句是酱紫的:正常: select * from [User] where userName like '%admin%' 参数化: select * from [User] where userName like @userName这样就查出了包括admin关键字的记录就是这个简单的语句,在参数化的时候怎么也查不出来,去拼like后面的字符串拼成酱紫的: 错误: new SqlParameter("@userName", string.Format("%'{0}'%", userName)); 错误: n
阅读全文
摘要:publicclassBitmapHelper{///<summary>///生成缩略图///</summary>///<paramname="originalImagePath">源图路径(物理路径)</param>///<paramname="thumbnailPath">缩略图路径(物理路径)</param>///<paramname="width">缩略图宽度</param>///<paramname="height
阅读全文
摘要:都在注释里了,不多说了///<summary>///DataReader转泛型///</summary>///<typeparamname="T">传入的实体类</typeparam>///<paramname="objReader">DataReader对象</param>///<returns></returns>publicstaticIList<T>ReaderToList<T>(thisIDataReaderobjReader
阅读全文
摘要:今天一个朋友问我,为什么不能使用Process.Start()启动梦幻,我看了一下也没有问题额。很是奇怪,他里Start方法里面传的是主程序的路径,说死也不能获取列表,我以为是游戏的问题,就手动点了桌面上的快捷方式,我了个去,竟然没有问题,于是就有了下面的代码。 搞定……System.Diagnostics.Processp=newProcess();p.StartInfo.UseShellExecute=true;p.StartInfo.FileName=@"C:\DocumentsandSettings\AllUsers\桌面\梦幻西游.LNK";p.Start();
阅读全文
摘要:安装:(另存为.bat文件)c:\windows\microsoft.net\framework\v2.0.50727\InstallUtil.exe您的服务.exepause卸载:(别存为.bat文件)c:\windows\microsoft.net\framework\v2.0.50727\InstallUtil.exe/u您的服务.exepause
阅读全文
摘要:原文地址:http://msdn.microsoft.com/zh-cn/library/65zzykke.aspx创建迭代器最常用的方法是对IEnumerable接口实现GetEnumerator方法,例如:publicSystem.Collections.IEnumeratorGetEnumerator(){for(inti=0;i<10;i++){yieldreturni;}}GetEnumerator方法的存在使得类型成为可枚举的类型,并允许使用foreach语句。如果上面的方法是ListClass的类定义的一部分,则可以对该类使用foreach,如下所示:staticvoidM
阅读全文
摘要:找到C:\WINDOWS\system32\drivers\etc里的hosts,用记事本打开,在最后面输入以下203.208.46.29 youtube.com 203.208.46.29 http://www.youtube.com/ 203.208.46.29 gdata.youtube.com 203.208.46.29 m.youtube.com 203.208.46.29 help.youtube.com 74.125.71.116 upload.youtube.com 203.208.46.29 accounts.youtube.com 203.208.46.29 insight
阅读全文
摘要:Global.asax文件中处理两类事件1、 对每次请求都发生的事件,2、 只在某些特定情况下才发生的事件。请求的事件按如下顺序发生。(1)Application_BeginRequest() 这个方法在每次请求开始时被调用(2)Application_AuthenticateRequest()。这个方法在执行验证前发生,这是创建你自己的验证逻辑的起点。(3)Application_AuthorizeRequest()。发生在用户验证(识别)后,此时应该确定用户的权限。你可以用这个方法给用户赋予特殊的权限。(4)Application_ResolveRequestCache()。这个方法常和输
阅读全文
摘要:在页面上的HTML服务器控牛的声明和普通的静态HTML标签的声明一样,使用附加的runat="server"特性,充高尔夫Asp.net处理服务器类,并把它们翻译成对应的.net类的实例。//在Page_Load事件中添加如下代码protectedvoidPage_Load(objectsender,EventArgse){HtmlTableTable=newHtmlTable();Table.CellPadding=5;Table.CellSpacing=5;Table.Border=1;HtmlTableRowrow;HtmlTableCellcell;for(inti
阅读全文
摘要:加密:Convert.ToBase64String(); 微软文档:传送门解密:Convert.FromBase64String(); 微软文档:传送门我们编写两个方法,用于加密和解密publicstringbase64Encode(stringstr) //加密{ byte[]bt=Encoding.UTF8.GetBytes(str);returnConvert.ToBase64String(bt);}publicstringbase64Decode(stringbase64str,stringcodename)//解密{ byte[]bt=Convert.FromBase64St...
阅读全文