C#检测DataSet是否为空,下面的代码片段通过判断DataSet的Table数量来判断DataSet是否为空DataSet dt = new DataSet();if (dt.Tables.Count>0) // has tables in it{ //dataset is not empty}else {// otherw……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1579浏览 2259个赞
下面以链接sql server为例,默认情况下连接池的大小为100个,你可以根据需要设定连接池,下面设置为最大75个,最小5个DATA SOURCE=(LOCAL);Initial Catalog=sharejsDB;User ID=root;Password=****;Max Pool SIZE=75;Min Pool SIZE=5;……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2441浏览 969个赞
下面的代码可以实现异步发送邮件,等邮件发送出去后会自动调用回调函数,这样在发送邮件时就不会卡住程序不动了MailMessage m = new MailMessage ("item@75271.com", "raja@75271.com", "This is the subject ……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2545浏览 1969个赞
C#中通过SSL发送邮件MailMessage m = new MailMessage ("item@75271.com", "raja@75271.com", "This is the subject for the authorized email.", &qu……继续阅读 » 水墨上仙 4年前 (2021-03-20) 3083浏览 607个赞
C#中使用smtp发送邮件MailMessage m = new MailMessage ("jane@75271.com", "ben@75271.com", "This is the subject for the email.", "This is ……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1741浏览 730个赞
C#发送HTML格式的邮件MailMessage m = new MailMessage();m.From = new MailAddress("ir@w3mentor.com", "Raja Item");m.To.Add(new MailAddress("su@w3mentor.com"……继续阅读 » 水墨上仙 4年前 (2021-03-20) 3113浏览 2075个赞
C#发送带附件的邮件MailMessage m = new MailMessage();m.From = new MailAddress("ir@75271.com", "Raja Item");m.To.Add(new MailAddress("su@75271.com", "S……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2907浏览 1005个赞
C#发送邮件并抄送给多个邮件接收者MailMessage m = new MailMessage();m.From = new MailAddress("ir@75271.com", "Raja Item");m.To.Add(new MailAddress("su@75271.com", ……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2656浏览 2505个赞
C#读取命令行参数的代码下面的代码用于从命令行读取参数,参数个数不定,程序将会输出用户在命令行输入的所有参数列表using System; namespace W3M{ class ArgsExample { public static int Main(string[] args) { f……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1717浏览 848个赞
C#创建、读取和修改Excelwindows下我们可以通过 Jet OLE DB访问Excel,就行访问数据库一样// Namespaces, Variables, and Constantsusing System;using System.Configuration;using System.Data; private OleDbData……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1269浏览 506个赞
C#连接ODBC数据源演示代码// Namespaces, variables, and constantsusing System;using System.Configuration;using System.Data;using System.Data.Odbc; private void CButton_Click(object se……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2458浏览 1516个赞
Asp.Net MVC中如果要通过ActionLink生成链接,传递参数可以通过下面的代码实现<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&qu……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2942浏览 679个赞
ASP.NET MVC中通过Html.ActionLink动态生成链接C# MVC模式下HTML.ActionLink() 用于生成指定Action的丽娜姐,非常有用<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" ➥Inh……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1646浏览 1197个赞
C#通过正则表达式去除所有html标签,只要包含在里面的都会被认为是html标签string myInput="<a href=''>clean me up</a><br/>";string strippedString = Regex.Replace(myInput,@&qu……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1500浏览 2500个赞
Convert类的静态方法FromBase64String 可以讲base64编码的字符串反转为二进制数据byte[]格式,从而恢复编码后的bitmap位图byte[] imageBytes = bmpAsString.Base64DecodeString();using (FileStream fstrm = new FileStream(@&quo……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1298浏览 1681个赞
C#解码base64编码的二进制数据通过在Convert类的静态方法Convert.FromBase64String,可以讲base64编码的字符串解码为等效的byte []数组。using System;static class MyModClass{public static byte[] Base64DecodeString(this st……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1832浏览 2063个赞
C#将一个bitmap位图通过base64编码成一个字符串byte[] image = null;using (FileStream filestrm = new FileStream(@"C:\mypic.bmp",FileMode.Open, FileAccess.Read)){ using (BinaryReader re……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1822浏览 2253个赞
C#中对二进制数据进行base64编码using System;using System.IO;static class MyModClass{public static string Base64EncodeBytes(this byte[] inBytes){return (Convert.ToBase64String(inBytes))……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1467浏览 1349个赞
C#从字符串中的指定位置移除子字符串,字符串自带remove方法可以用于删除子字符串,Remove的第一个参数为子字符串开始位置,第二个参数为要删除的子字符串长度string name = "Raja, Item";name = name.Remove(4, 1);Console.WriteLine(name); ……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1878浏览 2509个赞
C#查找列表中所有重复出现的元素public T[] GetDuplicates(T inputValue){ List<T> duplicates = new List<T>( ); for (int i = 0; i < this.Count; i++) { if (this[i].Equals(inputV……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2839浏览 2819个赞
这是使用linq计算元素在列表中出现的次数,调用方法非常简单,和sql语句很像// Count the number of times an item appears in this listpublic static int CountTimes<T>(this List<T> inputList, T searchItem)……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2219浏览 1778个赞
C#的Array对象自带反转功能,但是下面的代码完全通过自定义的算法来实现数组反转public static void ReverseArray<T>(this T[] inputArray){ T temp = default(T); if (inputArray == null) throw new ArgumentNull……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1565浏览 2223个赞
用C#自带的函数反转数组,C#的Array对象自带反转功能,代码如下int[] someArray = new int[5] {1,2,3,4,5};Array.Reverse(someArray);……继续阅读 » 水墨上仙 4年前 (2021-03-20) 3164浏览 277个赞
C#获取文件创建时间,主要用到了FileInfo的CreattionTime属性using System;using System.IO;class Class1 { static void Main(string[] args) { string[] cla = Environment.GetCommandLineArgs(……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2224浏览 474个赞
C#返回目录的最后访问时间using System;using System.IO; class MainClass { static void Main(string[] args) { FileInfo file = new FileInfo("c:\\a.txt"); // Di……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2652浏览 885个赞
C#从获取指定目录下的所有文件列表using System;using System.IO; class MainClass { static void Main(string[] args) { DirectoryInfo dir = new DirectoryInfo("c:\\"); ……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1347浏览 730个赞
JavaScript的Math对象包含了一个round方法用于对数字进行四舍五入操作,下面的代码详细演示了其用法<!DOCTYPE html><html><body><p id="demo">Click the button to round the number 2.5 to ……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2643浏览 1295个赞
JS数组带有一个unshift方法可以再数组前面添加若干个元素,下面是详细的代码演示<!DOCTYPE html><html><body><p id="demo">Click the button to add elements to the array.</p>……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2027浏览 2494个赞
我们可以通过JS数组的splice方法在执行的位置插入新的元素,非常简单<!DOCTYPE html><html><body><p id="demo">Click the button to add elements to the array.</p><bu……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2402浏览 2575个赞
JS数组的sort方法支持使用函数作为参数,下面的代码演示了JS数组如何通过sort对数字类型的数组进行倒序排序<!DOCTYPE html><html><body><p id="demo">Click the button to sort the array.</p>……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1572浏览 243个赞
JS数组的sort方法支持一个函数作为参数,下面的代码演示了JS数组如何实现数字的正序排列<!DOCTYPE html><html><body><p id="demo">Click the button to sort the array.</p><butt……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2071浏览 2851个赞
JS数组带有一个sort方法可以给数组排序,非常简单<!DOCTYPE html><html><body><p id="demo">Click the button to sort the array.</p><button onclick="my……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1515浏览 2834个赞
JS数组带有一个slice方法,可以获取数组的指定部分,下面的代码获取数组中的第二个和第三个元素<!DOCTYPE html><html><body><p id="demo">Click the button to extract the second and the third……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1249浏览 286个赞
JS中我们可以通过pop方法移除数组的最后一个元素,可以通过shift方法移除数组的第一个元素<!DOCTYPE html><html><body><p id="demo">Click the button to remove the first element of the a……继续阅读 » 水墨上仙 4年前 (2021-03-20) 3152浏览 925个赞
下面的代码演示了JS中如果通过数组的reverse方法将数组元素反转过来<!DOCTYPE html><html><body><p id="demo">Click the button to reverse the order of the elements in the arr……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2877浏览 1585个赞
下面的代码演示了JS数组通过push方法添加一个元素到数组末尾<!DOCTYPE html><html><body><p id="demo">Click the button to add a new element to the array.</p><bu……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2711浏览 446个赞
下面的代码演示了JS数组的pop方法,可以用来移除数组的最后一个元素,实际上就是把数组当成堆栈使用<!DOCTYPE html><html><body><p id="demo">Click the button to remove the last array element.&……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1893浏览 427个赞
下面的代码演示了JS中如何通过contact函数链接多个数组<!DOCTYPE html><html><body><script>var parents = ["Jani", "Tove"];var brothers = ["Stale&quo……继续阅读 » 水墨上仙 4年前 (2021-03-20) 3236浏览 362个赞
下面的JS代码输出全部的cookie键值对照<!DOCTYPE html><html><body>Cookies associated with this document: <script>document.write(document.cookie);</script>&l……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2613浏览 1039个赞
下面的JS代码通过document.links获得网页中的所有超级链接数组,然后获得第一个链接的ID属性<!DOCTYPE html><html><body><h1>75271.com</h1><img src ="planets.gif" width=&quo……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2098浏览 2315个赞
下面的JS代码通过document.links获取网页中的所有超级链接,从而获得超级链接的数量<!DOCTYPE html><html><body><img src ="planets.gif" width="145" height="126" ……继续阅读 » 水墨上仙 4年前 (2021-03-20) 1986浏览 1472个赞
下面的代码通过document.images获取网页中的所有图片,然后获取第一个图片的id属性<!DOCTYPE html><html><body><img id="klematis lilac" border="0" src="klematis.jpg&……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2092浏览 1494个赞
下面的JS代码通过document.forms数组获取网页中的表单,并返回第一个表单的name属性,即名字<!DOCTYPE html><html><body><h1>75271.com</h1><form name="Form1"></form&g……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2898浏览 902个赞
下面的JS代码通过document.images数组获取网页中图片数量<!DOCTYPE html><html><body><h1><a href="http://www.75271.com">脚本分享网</a></h1><img bor……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2353浏览 2548个赞
下面的JS代码通过document.forms数组获得网页中表单(form)的数量<!DOCTYPE html><html><body><h1>75271.com</h1><form name="Form1"></form><form ……继续阅读 » 水墨上仙 4年前 (2021-03-20) 2246浏览 759个赞