随笔分类 - 常用算法
摘要:1.序列化 public static byte[] SerializeObject(object obj) { if (obj == null) return null; MemoryStream ms = new MemoryStream(); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(ms, obj); ms.Position = 0; ...
阅读全文
摘要:using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Runtime.Serialization.Formatters.Binary;using System.Security.Cryptography;using System.Text;//xlding, 2013/07/25namespace Gemr.Utils{ public class CommonAlgorithms { #region Sort public ...
阅读全文
摘要:public StringBuilder GetMessageDiagest(string content) { if (string.IsNullOrEmpty(content) == false) { MD5 md5 = new MD5CryptoServiceProvider(); byte[] data = new CommonAlgorithms().ConvertStringToByteArray(content); byte[] result = md5.ComputeHash(data); StringBuilder sb = new StringBuilder(); for.
阅读全文
摘要:"^\d+$" //非负整数(正整数 + 0) "^[0-9]*[1-9][0-9]*$" //正整数 "^((-\d+)|(0+))$" //非正整数(负整数 + 0) "^-[0-9]*[1-9][0-9]*$" //负整数 "^-?\d+$" //整数 "^\d+(\.\d+)?$" //非负浮点数(正浮点数 + 0) "^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9]
阅读全文
摘要:DeleteBasicProtocolRecursively private void DeleteBasicProtocolRecursively(ModelContainer container, string parentId, string strProtocolId) { #region BasicProtocolStructure var nodes = from node in container.BasicProtocolStructures where node.Pid == parentId select node; if (nodes...
阅读全文
摘要:using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Qhr.QhrService; namespace Qhr { public partial class test : System.Web.UI.Page { Qhr.QhrService.QhrServiceClient proxy = new QhrService...
阅读全文
摘要:代码:<htmlxmlns="http://www.w3.org/1999/xhtml"> <headrunat="server"> <title>无标题页</title> </head> <body> <formid="form1"runat="server"> <divstyle="text-align:center;"> <divstyle="margin:5px;float:l
阅读全文
摘要:要求:1、总长8位;2、至少一个大写字母;3、至少一个小写字母;4、至少一个数字(0~9);5、至少一个特殊字符; using System; using System.Collections.Generic; using System.Text; /**************************************************** * Author:quietwalk * Date:2011-12-02 * Fuction:Generate a random password that consists of mixed case (at least...
阅读全文
摘要:http://xahanjianxin.blog.163.com/blog/static/4458605720082215539592/ASCII, American Standard Code for Information Interchange 念起来像是 "阿斯key",定义从 0 到 127 的一百二十八个数字所代表的英文字母或一样的结果与意义。由于只使用7个位元(bit)就可以表示从0到127的数字,大部分的电脑都使用8个位元来存取 字元集(character set),所以从128到255之间的数字可以用来代表另一组一百二十八个符号,称为 extended A
阅读全文
摘要:http://hi.baidu.com/w01fer/blog/item/93d185119a58ca0b213f2ea2.htmlLUHN算法,主要用来计算信用卡等证件号码的合法性。 next section from:http://en.wikipedia.org/wiki/Luhn_algorithm The Luhn algorithm or Luhn formula, also known as the "modulus 10" or "mod 10" algorithm, is a simple checksum formula used t
阅读全文
摘要:http://blog.bossma.cn/dotnet/csharp_winform_lan_get_ip_and_computername/c#可以遍历局域网计算机,获取全部计算机的名称和IP地址,网上提供了相关的几种方法,并对效率进行了比较,但是没有对各种方法进行比较,以确定可以使用的情况。这篇文章将对这几种方法进行分析,以帮助了解各种方法适用的情况。 using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using
阅读全文
摘要:添加外键:alter table MemberMemberRoleadd constraint FK_MemberMemberRole_Projects_Id foreign key (Project_Id) references Projects(Id) on update cascade ;
阅读全文
摘要://Author:quietwalk//Date:2011-06-13//Operation:过滤数字型数据的后面的0,保证只有一个0//输入:45.000//输出:45.0public static string trim0(string ls_original) { int iLength, j; j = 0; //iLength=len(ls_original); iLength = ls_original.Length; string ls_temp; ls_temp = ls_original; string strR1; if (iLength > 2) { //strR1=
阅读全文