C#通过StreamWriter和StreamReader写入和读取文件/*C#: The Complete Reference by Herbert Schildt Publisher: Osborne/McGraw-Hill (March 8, 2002)ISBN: 0072134852*/// Demonstrate String……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2246浏览 2454个赞
在Razor中使用for each语句和后端C#代码类似,更容易遍历输出html内容<html><body><ul>@foreach (var x in Request.ServerVariables) {<li>@x</li>}</ul></body>……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2948浏览 906个赞
在Razor页面中使用for循环语句和在后端的C#代码使用for循环语句没有什么区别,但是在页面里面for循环语句可以输出更多html格式的内容,非常方便,无需使用Response.Write的方式<html><body>@for(var i = 10; i < 21; i++){<p>Line @i&……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2033浏览 1189个赞
C#自定义繁体和简体字库实现中文繁体和简体之间的转换,由于需要自定义繁体和简体的一对一字库,所以代码会比较长代码转自:http://blog.csdn.net/mypc2010/using System;using System.Collections.Generic;using System.Linq;using System.Text;u……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1238浏览 2117个赞
一个C#实现异步调用的简单范例代码代码转自:http://blog.csdn.net/mypc2010//* * User: MXi4oyu * Email:798033502@qq.com * Date: 2013-7-18 * Time: 19:50 * */using System;using System.Threading……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2680浏览 857个赞
SqlHelper其实是我们自己编写的一个类,使用这个类目的就是让使用者更方便、更安全的对数据库的操作,既是除了在SqlHelper类以外的所有类将不用引用对数据库操作的任何类与语句,无须担心数据库的连接与关闭的问题。转自:http://blog.csdn.net/dandanzmc/article/details/9345937{ ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3042浏览 1293个赞
C#操作PowerPoint的基本代码,包括打开ppt文件、读取幻灯页,插入幻灯片,自动播放等using System;using System.Collections.Generic;using System.Linq;using System.Text;using OFFICECORE = Microsoft.Office.Core;us……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2274浏览 2940个赞
这个C#类包含了各种常用数据验证的函数,包含验证是否是数字,校验email格式,区分中英文截取字符串,区分中英文计算字符串长度,检测是否包含中文字符,判断是否包含特定字符等using System;using System.Text;using System.Web;using System.Web.UI.WebControls;using S……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2498浏览 1635个赞
c#生成注册码using System;using System.Management;using System.Security.Cryptography;using System.IO;using System.Collections.Generic;using System.Text;namespace xingming_reg{……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2584浏览 698个赞
c#简单分页using System;using System.Collections.Generic;using System.Text;namespace WindowsApp{ class Paging { private int rowsPerPage; //每页显示的记录数 priv……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1965浏览 2829个赞
C#操作sqlite(包含中文支持)using System;using System.Data;using System.Text.RegularExpressions;using System.Xml;using System.IO;using System.Collections;using System.Data.SQLite;……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2776浏览 1874个赞
一个简单的C#多线程间同步的例子using System;using System.Collections;using System.Collections.Generic;using System.Threading;////// 在开发中经常会遇到线程的例子,如果某个后台操作比较费时间,我们就可以启动一个线程去执行那个费时的操作,同时程……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2791浏览 135个赞
C#常用操作1. StreamWriter - 文件写入类StreamWriter s = new StreamWriter(address + "/Menu.ini", true);s.WriteLine(openFileDialog1.FileName);s.Flush();s.Close();2. StreamRe……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2858浏览 2922个赞
VC中提供了API函数进行INI文件的读写操作,但是微软推出的C#编程语言中却没有相应的方法,下面是一个C# ini文件读写类,从网上收集的,很全,就是没有对section的改名功能。using System;using System.IO;using System.Runtime.InteropServices;using System.Tex……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2442浏览 2701个赞
C# 实现的 AES 加密算法using System;using System.IO;using System.Security.Cryptography; //// Sample encrypt/decrypt functions// Parameter checks and error handling// are ommited ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2481浏览 2733个赞
C#操作SQL Server通用类using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Collections;using System.Data.SqlClient;……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2467浏览 1208个赞
没有返回值,没有参数传递。MySqlConnection myConnection; myConnection = new MySqlConnection();myConnection.ConnectionString = "database="+database+";server="+ se……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1386浏览 1509个赞
C# 连接 MySQL 数据库的代码using System;using System.Data; class MySqlConnect { static void Main() { string connString = @"Data Source=server;Database=……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2892浏览 2017个赞
C#实现的字符串加密和解密方法public class Encrypt{//默认密钥向量private static byte[] Keys = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF }; /// <summary>/// DES加密字符串/// </su……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2183浏览 153个赞
C#实现写入文本文件内容功能private void write_txt(string str1, string str2, string str3){ System.DateTime currentTime = System.DateTime.Now; string strYMD = currentTime.ToString(&qu……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1885浏览 1605个赞
需要mysql.data.dllusing System;using System.Collections.Generic;using System.Text;using System.Windows.Forms;using System.Data;using System.Text.RegularExpressions;///using……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3182浏览 1106个赞
c# 简单的系统管理命令using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;using System.Diagnostics;using System.Runtime.InteropS……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1960浏览 1367个赞
C#编写的FTP上传简单工具类using System;using System.Net;using System.IO;using System.Text;using System.Net.Sockets;using System.Collections;using System.Collections.Generic;namespac……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2245浏览 2905个赞
C#目录内文件批量查找替换字符串内容using System;using System.Collections.Generic;using System.Text;using System.Text.RegularExpressions;using System.IO;public class MyClass{ public st……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2887浏览 1482个赞
这个C#类封装的DES加密解密,可以使用默认秘钥进行加密、解密,也可以自定义秘钥进行加密、解密,调用简单方便。using System;using System.Security.Cryptography; using System.Text;namespace DotNet.Utilities{ /// <summary> ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2947浏览 2597个赞
C#图片剪裁类public class ImageCut{ /// <summary> /// 剪裁 -- 用GDI+ /// </summary> /// <param name="b">原始Bitmap</param> /// <pa……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1702浏览 2309个赞
c#九九乘法表using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Multiplication{ class Program { static void Main(string[]……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2864浏览 985个赞
C#统计目录中文件MD5值,并存入剪贴板中using System.IO;using System.Security.Cryptography;using System.Collections;using System.Windows.Forms; IDataObject iData = Clipboard.GetDataObject(); ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2711浏览 1770个赞
C#除去以//开始的注释using System.IO; using System.Collections; static string deleteComments(string s) //去掉以//开始的注释 { if (s == null) return s; int pos = s.In……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1187浏览 449个赞
C#解压缩单个zip格式文件using System.IO;using System.IO.Compression;string sourceFile=@"D:\2.zip";string destinationFile=@"D:\1.txt"; private const long BUFFER……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2884浏览 2716个赞
C#压缩单个zip格式文件using System.IO;using System.IO.Compression;string sourceFile=@"C:\1.txt";string destinationFile=@"D:\2.zip"; private const long BUFFER_SIZE……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2747浏览 759个赞
C# 字符串数组转换为整形数组/// <summary>/// 字符串数组转换整形数组/// </summary>/// <param name="Content">字符串数组</param>/// <returns></returns>public ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2743浏览 2925个赞
C#1433全自动抓鸡代码片段namespace WMIScanner{using System;using System.Collections;using System.Data.SqlClient;using System.IO;using System.Threading;using System.Windows.Forms;……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3084浏览 1949个赞
c#打开网页using System.Diagnostics;Process.Start(@"C:\Program Files\Internet Explorer\iexplore.exe", "http://ant.sourceforge.net/");……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2773浏览 498个赞
c# 运行cmd命令using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;using System.Diagnostics;namespace ConsoleApplication1……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1945浏览 1550个赞
C#复制文件夹的文件到另一个文件夹private void CopyDir(string srcPath, string aimPath) { try { // 检查目标目录是否以目录分割字符结束如果不是则添加 if (aimPath[aimPath.Length - 1] != System.IO.Path.DirectorySeparat……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3012浏览 1887个赞
实现C#关闭Windows XP的代码using System; using System.Runtime.InteropServices; class shoutdown{ [StructLayout(LayoutKind.Sequential, Pack=1)] internal struct TokPriv1Luid { ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2751浏览 2201个赞
通过对字符的unicode编码进行判断来确定字符是否为中文。protected bool IsChineseLetter(string input,int index){int code = 0;int chfrom = Convert.ToInt32("4e00", 16); //范围(0x4e00~0x9fff)转换成in……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3074浏览 635个赞
C#中 让程序只能启动一次System.Threading.Mutex mutex = new System.Threading.Mutex(false, "ThisShouldOnlyRunOnce"); bool Running = !mutex.Wa……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2584浏览 2000个赞
C#解决约瑟夫问题代码using System;namespace heut{ class Class1 { public static void Main() { int[] a = new int[17]; int sum = 17;//共有8个人;……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3192浏览 2009个赞
C#代码解决约瑟夫问题设有n个人围坐一圈,现以某个人开始报数,数到m的人出列,接着从出列的下一个人开始重新报数,数到m的人又出列,如此下去,直到所有人都出列为止.按出列顺序输出.public class Josephas //从第start人开始计数,以alter为单位循环记数出列,总人数为total public int [……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2386浏览 2515个赞
C#导出数据到CVS文件的通用类代码,通过这个类可以很简单的定义数据格式,并导出到CVS文件//这里写了一个通用的类 using System;using System.Data;using System.Configuration;using System.Collections.Generic;using System.Web;usin……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1644浏览 165个赞
C#导出数据到Excel的代码using System;using System.Collections.Generic;using System.Text;using System.Data;using System.Windows.Forms;using System.IO; namespace TopAPI{ class E……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3067浏览 742个赞
C#中通过二维数组创建矩阵 static double[][] CreateMatrix(int rows, int cols) { double[][] result = new double[rows][]; for (int i = 0; i < rows; ++i) result[i] = ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3165浏览 832个赞
C#中矩阵乘法演示代码static double[][] MatrixMultiplication(double[][] matrixOne, double[][] matrixTwo){ int aRows = matrixOne.Length; int aCols = matrixOne[0].Length; int bRows = mat……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2348浏览 1305个赞