C#创建、读取和修改Excelwindows下我们可以通过 Jet OLE DB访问Excel,就行访问数据库一样// Namespaces, Variables, and Constantsusing System;using System.Configuration;using System.Data; private OleDbData……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2831浏览 1255个赞
C#连接ODBC数据源演示代码// Namespaces, variables, and constantsusing System;using System.Configuration;using System.Data;using System.Data.Odbc; private void CButton_Click(object se……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2254浏览 1666个赞
Asp.Net MVC中如果要通过ActionLink生成链接,传递参数可以通过下面的代码实现<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&qu……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2956浏览 2624个赞
ASP.NET MVC中通过Html.ActionLink动态生成链接C# MVC模式下HTML.ActionLink() 用于生成指定Action的丽娜姐,非常有用<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" ➥Inh……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2410浏览 841个赞
C#通过正则表达式去除所有html标签,只要包含在里面的都会被认为是html标签string myInput="<a href=''>clean me up</a><br/>";string strippedString = Regex.Replace(myInput,@&qu……继续阅读 » 水墨上仙 6年前 (2021-03-20) 1533浏览 1259个赞
Convert类的静态方法FromBase64String 可以讲base64编码的字符串反转为二进制数据byte[]格式,从而恢复编码后的bitmap位图byte[] imageBytes = bmpAsString.Base64DecodeString();using (FileStream fstrm = new FileStream(@&quo……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2006浏览 1009个赞
C#解码base64编码的二进制数据通过在Convert类的静态方法Convert.FromBase64String,可以讲base64编码的字符串解码为等效的byte []数组。using System;static class MyModClass{public static byte[] Base64DecodeString(this st……继续阅读 » 水墨上仙 6年前 (2021-03-20) 3290浏览 877个赞
C#将一个bitmap位图通过base64编码成一个字符串byte[] image = null;using (FileStream filestrm = new FileStream(@"C:\mypic.bmp",FileMode.Open, FileAccess.Read)){ using (BinaryReader re……继续阅读 » 水墨上仙 6年前 (2021-03-20) 1913浏览 352个赞
C#中对二进制数据进行base64编码using System;using System.IO;static class MyModClass{public static string Base64EncodeBytes(this byte[] inBytes){return (Convert.ToBase64String(inBytes))……继续阅读 » 水墨上仙 6年前 (2021-03-20) 3484浏览 2535个赞
C#从字符串中的指定位置移除子字符串,字符串自带remove方法可以用于删除子字符串,Remove的第一个参数为子字符串开始位置,第二个参数为要删除的子字符串长度string name = "Raja, Item";name = name.Remove(4, 1);Console.WriteLine(name); ……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2092浏览 2995个赞
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……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2564浏览 1132个赞
这是使用linq计算元素在列表中出现的次数,调用方法非常简单,和sql语句很像// Count the number of times an item appears in this listpublic static int CountTimes<T>(this List<T> inputList, T searchItem)……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2186浏览 2145个赞
C#的Array对象自带反转功能,但是下面的代码完全通过自定义的算法来实现数组反转public static void ReverseArray<T>(this T[] inputArray){ T temp = default(T); if (inputArray == null) throw new ArgumentNull……继续阅读 » 水墨上仙 6年前 (2021-03-20) 1850浏览 1888个赞
用C#自带的函数反转数组,C#的Array对象自带反转功能,代码如下int[] someArray = new int[5] {1,2,3,4,5};Array.Reverse(someArray);……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2571浏览 2390个赞
C#获取文件创建时间,主要用到了FileInfo的CreattionTime属性using System;using System.IO;class Class1 { static void Main(string[] args) { string[] cla = Environment.GetCommandLineArgs(……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2994浏览 524个赞
C#返回目录的最后访问时间using System;using System.IO; class MainClass { static void Main(string[] args) { FileInfo file = new FileInfo("c:\\a.txt"); // Di……继续阅读 » 水墨上仙 6年前 (2021-03-20) 3459浏览 1726个赞
C#从获取指定目录下的所有文件列表using System;using System.IO; class MainClass { static void Main(string[] args) { DirectoryInfo dir = new DirectoryInfo("c:\\"); ……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2685浏览 854个赞
JavaScript的Math对象包含了一个round方法用于对数字进行四舍五入操作,下面的代码详细演示了其用法<!DOCTYPE html><html><body><p id="demo">Click the button to round the number 2.5 to ……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2730浏览 2690个赞
JS数组带有一个unshift方法可以再数组前面添加若干个元素,下面是详细的代码演示<!DOCTYPE html><html><body><p id="demo">Click the button to add elements to the array.</p>……继续阅读 » 水墨上仙 6年前 (2021-03-20) 1733浏览 2382个赞
我们可以通过JS数组的splice方法在执行的位置插入新的元素,非常简单<!DOCTYPE html><html><body><p id="demo">Click the button to add elements to the array.</p><bu……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2506浏览 1471个赞
JS数组的sort方法支持使用函数作为参数,下面的代码演示了JS数组如何通过sort对数字类型的数组进行倒序排序<!DOCTYPE html><html><body><p id="demo">Click the button to sort the array.</p>……继续阅读 » 水墨上仙 6年前 (2021-03-20) 1650浏览 805个赞
JS数组的sort方法支持一个函数作为参数,下面的代码演示了JS数组如何实现数字的正序排列<!DOCTYPE html><html><body><p id="demo">Click the button to sort the array.</p><butt……继续阅读 » 水墨上仙 6年前 (2021-03-20) 3185浏览 1764个赞
JS数组带有一个sort方法可以给数组排序,非常简单<!DOCTYPE html><html><body><p id="demo">Click the button to sort the array.</p><button onclick="my……继续阅读 » 水墨上仙 6年前 (2021-03-20) 1904浏览 2942个赞
JS数组带有一个slice方法,可以获取数组的指定部分,下面的代码获取数组中的第二个和第三个元素<!DOCTYPE html><html><body><p id="demo">Click the button to extract the second and the third……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2626浏览 1359个赞
JS中我们可以通过pop方法移除数组的最后一个元素,可以通过shift方法移除数组的第一个元素<!DOCTYPE html><html><body><p id="demo">Click the button to remove the first element of the a……继续阅读 » 水墨上仙 6年前 (2021-03-20) 3405浏览 2072个赞
下面的代码演示了JS中如果通过数组的reverse方法将数组元素反转过来<!DOCTYPE html><html><body><p id="demo">Click the button to reverse the order of the elements in the arr……继续阅读 » 水墨上仙 6年前 (2021-03-20) 1886浏览 2063个赞
下面的代码演示了JS数组通过push方法添加一个元素到数组末尾<!DOCTYPE html><html><body><p id="demo">Click the button to add a new element to the array.</p><bu……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2741浏览 453个赞
下面的代码演示了JS数组的pop方法,可以用来移除数组的最后一个元素,实际上就是把数组当成堆栈使用<!DOCTYPE html><html><body><p id="demo">Click the button to remove the last array element.&……继续阅读 » 水墨上仙 6年前 (2021-03-20) 1823浏览 2342个赞
下面的代码演示了JS中如何通过contact函数链接多个数组<!DOCTYPE html><html><body><script>var parents = ["Jani", "Tove"];var brothers = ["Stale&quo……继续阅读 » 水墨上仙 6年前 (2021-03-20) 3066浏览 2889个赞
下面的JS代码输出全部的cookie键值对照<!DOCTYPE html><html><body>Cookies associated with this document: <script>document.write(document.cookie);</script>&l……继续阅读 » 水墨上仙 6年前 (2021-03-20) 1949浏览 1327个赞
下面的JS代码通过document.links获得网页中的所有超级链接数组,然后获得第一个链接的ID属性<!DOCTYPE html><html><body><h1>75271.com</h1><img src ="planets.gif" width=&quo……继续阅读 » 水墨上仙 6年前 (2021-03-20) 3020浏览 927个赞
下面的JS代码通过document.links获取网页中的所有超级链接,从而获得超级链接的数量<!DOCTYPE html><html><body><img src ="planets.gif" width="145" height="126" ……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2194浏览 1808个赞
下面的代码通过document.images获取网页中的所有图片,然后获取第一个图片的id属性<!DOCTYPE html><html><body><img id="klematis lilac" border="0" src="klematis.jpg&……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2398浏览 1735个赞
下面的JS代码通过document.forms数组获取网页中的表单,并返回第一个表单的name属性,即名字<!DOCTYPE html><html><body><h1>75271.com</h1><form name="Form1"></form&g……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2838浏览 2063个赞
下面的JS代码通过document.images数组获取网页中图片数量<!DOCTYPE html><html><body><h1><a href="http://www.75271.com">脚本分享网</a></h1><img bor……继续阅读 » 水墨上仙 6年前 (2021-03-20) 3313浏览 1177个赞
下面的JS代码通过document.forms数组获得网页中表单(form)的数量<!DOCTYPE html><html><body><h1>75271.com</h1><form name="Form1"></form><form ……继续阅读 » 水墨上仙 6年前 (2021-03-20) 3252浏览 1177个赞
下面的JS代码通过document.archors数组获取第一个archor的innerHTML<!DOCTYPE html><html><body><a name="html">75271.com</a><br><a name="css……继续阅读 » 水墨上仙 6年前 (2021-03-20) 1962浏览 1315个赞
JavaScript返回网页中锚定的数目,下面的JS代码获取页面中的anchor数量<!DOCTYPE html><html><body><a name="html">HTML Tutorial</a><br><a name="css&……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2855浏览 1455个赞
下面的JS代码写在iframe里面,点击按钮后整个网页会转向指定的url,而不是只转iframe里的页面<!DOCTYPE html><html><head><script>function breakout(){if (window.top!=window.self) { windo……继续阅读 » 水墨上仙 6年前 (2021-03-20) 1620浏览 2329个赞
下面的JS代码可以替换当前页面为指定的URL<!DOCTYPE html><html><head><script>function replaceDoc() { window.location.replace("http://www.75271.com") }<……继续阅读 » 水墨上仙 6年前 (2021-03-20) 1863浏览 2165个赞
下面的JS代码可以重新加载当前页面<!DOCTYPE html><html><head><script>function reloadPage() { location.reload() }</script></head><body><……继续阅读 » 水墨上仙 6年前 (2021-03-20) 3882浏览 1552个赞
下面的JS代码点击按钮后可以控制网页转向指定的url<!DOCTYPE html><html><head><script>function newDoc() { window.location.assign("http://www.75271.com") }<……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2339浏览 916个赞
下面的JS代码返回当前浏览网页的相对路径,就是不要域名部分的路径,如:/codes/share<!DOCTYPE html><html><body><script>document.write(location.pathname);</script></body>……继续阅读 » 水墨上仙 6年前 (2021-03-20) 1929浏览 348个赞
JavaScript获取当前浏览网页的完整地址,JS中我们可以通过location对象的href来获取完整url地址<!DOCTYPE html><html><body><script>document.write(location.href);</script></b……继续阅读 » 水墨上仙 6年前 (2021-03-20) 2118浏览 1655个赞
JS中的location.host可以返回当前网址的主机名<!DOCTYPE html><html><body><script>document.write(location.host);</script></body></html>……继续阅读 » 水墨上仙 6年前 (2021-03-20) 3117浏览 2540个赞