C# 生成随机数的三种方法汇总转自:http://blog.csdn.net/jason20ming/article/details/8447851 开始,很简单地使用System.Random类来生成随机数。很快,问题就来了,发现当random的生成间隔小于1ms时,随机数就重复了(……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3095浏览 2962个赞
JQuery向asp.net ashx提交带中文的参数代码字符编码这个东西,一旦和中文打上交道就不可避免出现乱码,今天项目用到了JQuery向ashx提交中文参数的这一块,折腾了一天,开始是各种乱码,最后中算弄好了。来源:http://blog.csdn.net/wangqiuyun/article/details/8450964 ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2514浏览 463个赞
IsGUID函数用来判断字符串是否是GUIDpublic static bool IsGUID(string expression){ if (expression != null) { Regex guidRegEx = new Regex(@"^(\{{0,1}([0-9a-fA-F]){8}-([0-9……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3272浏览 2409个赞
这段代码展示了如何截取用户的点击事件,在相应点击事件之前先之行自己的代码// KeyDown event of some controlprivate void SomeControl_KeyDown(object sender, KeyEventArgs e){ // 1. Event is called directly after t……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1347浏览 2328个赞
设置窗体属性showinTask=false;加notifyicon控件notifyIcon1,为控件notifyIcon1的属性Icon添加一个icon图标;添加窗体最小化事件// this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged); //上面一行是主窗体Initi……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1867浏览 2864个赞
1,判断图片的宽和高的比例,然后进行缩放,以便于使缩略图不变形。2,DrawImage方法为缩略图绘制边框,这样,浏览起来比较美观。3,调用Save方法将生成的缩略图保存到指定的目录下。转自:http://blog.csdn.net/chifengchifeng/article/details/8439884 private void MakeT……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2547浏览 1443个赞
C# 操作INI配置文件代码演示详解转自:http://blog.csdn.net/laner0515/article/details/8439933 INI文件由节、键、值组成。节 [section]参数(键=值) name=value既然ini文件在初始化中使用,那么免不了的……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1616浏览 1937个赞
asp.net中字符串编码及编码转换转自:http://blog.csdn.net/haukwong/article/details/8433648 在项目开发中不少朋友都会遇到字符串编码、解码或者编码转换的问题。为了方便初学者朋友,我就在这里抛砖引玉地讲解一下吧。在C#中我们一般使用……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2292浏览 2828个赞
利用HttpURLConnection对象,我们可以向网络发送xml数据.StringBuilder xml = new StringBuilder();xml.append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");xml……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2545浏览 2920个赞
C# 控制list对象删除重复记录转自:http://blog.csdn.net/learner9023/article/details/8434528 两种比较实用的方法,一个是双循环,一个是hashset.一.循环public static List removeD……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1545浏览 2769个赞
随机把数组内的元素打乱,重新排列public static void Shuffle<T>(T[] array) { Random random = new Random(); for (int i = 0; i < 10; i++) { int i……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3156浏览 442个赞
C#通过递归实现文件及文件夹拷贝//**************************************************************************// /* //获得长路径的相对短路径名称 [DllImport("kernel32.dll", C……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3230浏览 848个赞
一个简单的字符串截取函数,可以指定截取位数,例如:输入(“This is way too long”, 11, “…”) 返回为 “This is way…”public static string Truncate(this string myString……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1662浏览 1985个赞
C#读取中文文件乱码的解方法FileStream aFile = new FileStream(SingleFile, FileMode.Open);StreamReader sr = new StreamReader(aFile, Encoding.GetEncoding("gb2312"), true);string Fil……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2407浏览 1024个赞
C#中double类型转化成字符串并指定要保留的小数位数double temp=3.1415926;(F)Fixed point:string str1=temp.toString("f1");//保留一位小数 四舍五入 结果:3.1(F)Fixed point:string str2=temp.toString("f……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3330浏览 855个赞
自动更新的软件的目的在于让客户不在为了寻找最新软件花费时间。也不用去到开发商的网站上查找。客户端的软件自动会在程序启动前查找服务器上最新的版本。和自己当前软件的版本比较,如果服务器的是最新版本。客户端则进行自动下载、解压、安装。当然了下载是要有网络的,并且用户可以根据提示去完成操作。再也不用为找不到最新版本的软件而头疼。转自:http://blog.csdn……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2788浏览 1268个赞
C#通过log4net进行异常记录C#中异常的记录也有一个模板,就是log4net。多的就不说了直接看怎么用的吧。 1、引用log4net.dll。2、实现log4net的方法。public class LogImplement { private ILog……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3420浏览 1900个赞
C#代码控制执行Dos命令或者外部命令, 在c#程序中,有时会用到调用cmd命令完成一些功能,于是在网上查到了如下方法,实现了c#执行DOS命令,并返回结果。 //dosCommand Dos命令语句 public string Execute(string dosCommand) { ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2034浏览 151个赞
C#获取本机IP地址和Mac地址的代码查找了几个方法,经过调试修改,下面这个方法能很好的获取到本地的IP和MAC地址。可以用于这方面的功能实现。主要是要添加System.Management的引用。using System;using System.Management;using System.Net; public class Program……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2232浏览 2456个赞
C#通过正则表达式抓取网页信息的类using System;using System.Data;using System.Configuration;using System.Net;using System.IO;using System.Text;using System.Collections.Generic;using Syste……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1476浏览 1639个赞
JavaScript Date formatting prototypeDate.prototype.format = function (sFormat, twelve) { // Returns: A string version of the date. // Usage: date_instance.format("d……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1970浏览 1379个赞
JavaScript中使用继承的代码演示// define the Person Classfunction Person() {} Person.prototype.walk = function(){ alert ('I am walking!');};Person.prototype.sayHello = fun……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2918浏览 563个赞
JavaScript对象查看器代码// obj: object to inspect// dest: destination to put the results in.function inspect(obj, dest) { // prefent for errors if(obj == undefined |……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2453浏览 975个赞
JavaScript将UPC转换成ISBN的代码if (indexisbn.indexOf("978") == 0) { isbn = isbn.substr(3,9); var xsum = 0; var add = 0; var i = 0; for (i = 0; i < 9; i++) {……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2354浏览 378个赞
使用此代码,可以将任何电子邮件地址编码为 HTML 字符实体,以防止被垃圾邮件程序收集。function encode_email($email='info@domain.com', $linkText='Contact Us', $attrs ='class="emailencoder&qu……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1760浏览 2176个赞
JavaScript从Mongo的id获得时间戳var timestamp = _id.toString().substring( 0, 8 );var date = new Date( parseInt( timestamp, 16 ) * 1000 );……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2108浏览 420个赞
javascript通过shift+click选择和反选checkbox的代码var lastChecked = null;var handleChecked = function(e) { if(lastChecked && e.shiftKey) { var i = $('input[type=&……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3178浏览 209个赞
JavaScript中的事件委托演示代码var addEvent = function (elem, eventType, func) { if ( elem.addEventListener ) addEvent = function (elem, eventType, func) { elem.add……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2310浏览 2328个赞
JavaScript通过Date-Mask将日期转换成字符串var MonthNames = ["January", "February", "March", "April", "May", "June", "July&qu……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2604浏览 1267个赞
JavaScript操作Cookie演示代码// My methods for setting, reading and deleting cookies.// I have methods to check for the existence of cookie names or values, // to retrieve by name or……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2236浏览 2760个赞
JS代码隐藏网页上点中的元素// Click on an element (image, etc.) to hide, press Escape when finished.// My site: andrew.dx.amjavascript:(function(){var d=document,useMine=true,prevEl;functi……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2799浏览 1796个赞
给网页上选中的文本添加临时注释的JS代码// Select some text in the current page and click the button to // add a comment; i.e. an editable textarea.// The comment is only temporary but a screensh……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2311浏览 713个赞
jQuery为html表格动态添加新的行<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1650浏览 1573个赞
JavaScript检测鼠标移动的方向代码function Start() { stage.addEventListener(MouseEvent.MOUSE_MOVE, CheckDirection); }Start(); var prevX=0;var prevY=0;var curX=0;var curY=0; va……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1905浏览 610个赞
可以随机生成指定长度的字符串,随机生成指定范围的数字等/** * Some functions about random */// By James from http://www.xinotes.org/notes/note/515/function randomString(length) { var chars = '0……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3342浏览 292个赞
js实现fixed布局的按钮条儿,仿gmail <html> <head> <title>fixed bar demo</title> <style type="text/css" media="screen">……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2865浏览 1793个赞
数据库被输入恶意代码,为了保证你的数据库的安全,你必须得小心去清理。有了下面一个超级方便的功能,即可快速清除数据库恶意代码。function cleanInput($input) { $search = array( '@]*?>.*?@si', // Strip out javascript ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1953浏览 244个赞
jQuery调用json代码片段演示<script type="text/javascript"> $(function () { $("#btnOK").click(function () { $.ajax({ ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3148浏览 972个赞
在Web的应用与设计中,全屏背景的制作越来越常见。你是使用超大超大的背景图片来实现呢?还是在使用JavaScript脚本来制作呢?我想这些都不是什么非常好的方法。个人认为CSS3中的background-size属性是一个非常NB的属性,能轻松的帮你实现全屏背景制作,简单易懂。我们只要把需要做为全屏背景的那张图片放在HTML标签中:html{ /* ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2102浏览 1709个赞
js判断是否是ie6浏览器//Pure JavaScript, no framework - NOTE: this must be placed in an onLoad event or after the body has loaded or it will result in an errorif(typeof document.body.st……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1715浏览 1919个赞
如果你使用css sprites,那么在ie6下并不能发挥sprites的作用,它还是会每次再重新加载这个图片,解决方法为为ie6添加下面这条js<!--[if IE 6]> <script type="text/javascript"> document.execCommand(&q……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3188浏览 2981个赞
在iPhone、iPad上测试最近项目,要让页面自适应缩放,使其适合设备屏幕。在GG上找的都介绍使用,但在我的项目中并没有产生任何的作用,后来只好在GG中搜索,终于找到一个js的代码,多次使用都能Ok。<script type="text/javascript" src="http://code.jquery.com……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1933浏览 1521个赞
python清除指定目录内的所有文件的script将脚本存储为stripscripts.py 调用语法 : python stripscripts.py 使用范例 : python stripscripts.py d:\myfiles# Hello, this is a script written in Python. See http://www.……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3099浏览 622个赞
jquery控制表单输入框的默认值操作代码<!DOCTYPE html><html><head><script type="text/javascript">$(document).ready(function() { $('.someClass')……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1866浏览 2217个赞
JavaScript对表格或者元素按照文本,数字或者日期排序// Sorting table columns correctly by text, number or date. There are other // versions, plugins, etc., for this but they either are restricted to……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2126浏览 280个赞