c#实现人民币大小写转换的代码using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Utility{ /// <summary> ///金钱转换成大写 DBA群: 22598298……继续阅读 » 水墨上仙 5年前 (2021-03-12) 3307浏览 2070个赞
C# 用Log4net记录日志代码演示 1、引入Log4net.dll到项目中2、在global.asax的程序启动服务添加代码:protected void Application_Start(Object sender, EventArgs e) { log4n……继续阅读 » 水墨上仙 5年前 (2021-03-12) 3378浏览 703个赞
C#验证码识别类,可以用于识别各种验证码的算法演示using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Drawing;using System.Drawing.Imaging;using System.R……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1827浏览 1676个赞
C#获取指定月指定周的日期范围 根据当前时间获取本月开始日期和结束日期 /// <summary> /// 获取指定月份指定周数的开始日期 /// </summary> /// <param name="year">年份</par……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1530浏览 663个赞
用EnumWindows 函数将枚举计算机上的所有现有窗口,但我们用System.Diagnostics名字空间的静态函数Process.GetProcesses()可以避免EnumWindows的互操作性问题Using System.Diagnostics; ... foreach ( Process p in Process.GetProc……继续阅读 » 水墨上仙 5年前 (2021-03-12) 3262浏览 168个赞
C#显示出正在运行的所有进程Using System.Diagnostics; ... foreach ( Process p in Process.GetProcesses() ) Console.WriteLine( p ); // string s = p.ToString(); ……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1490浏览 1060个赞
C#确保只有一个实例在运行public static Process RunningInstance() { Process current = Process.GetCurrentProcess(); Process[] processes = Process.GetProcessesByName (current.ProcessName); ……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1663浏览 1858个赞
C#获得本机ip地址string s=""; System.Net.IPAddress[] addressList = Dns.GetHostByName(Dns.GetHostName()).AddressList; for (int i = 0; i < addressList.Length; i ++) { s……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2739浏览 166个赞
C#解压GZip文件代码 public void ungzip(string path, string decomPath, bool overwrite) { //for overwriting purposes if (File.Exists(decomPath)) ……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2306浏览 2189个赞
C#判断年月日是否合法static bool ValidateDate(int y, int m, int d){ int[] a = { 31, (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30……继续阅读 » 水墨上仙 5年前 (2021-03-12) 3780浏览 2241个赞
C#模拟登陆OSC并获取Cookie/* * 由SharpDevelop创建。 * 用户: dodola * 日期: 2012/10/23 * 时间: 9:43 * * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件 */using System;using System.Collections.Generic;usi……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2475浏览 118个赞
本文提供了C#中文件下载的4中方法,分别带有演示代码来源:http://topic.csdn.net/u/20120822/10/d8115bb7-2f2a-4c2f-b0c1-aab68bcb1e3e.htmlusing System;using System.Data;using System.Configuration;using Syst……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1508浏览 2028个赞
C# 用 iTextSharp 将 PDF 转成文本using System;using System.IO; using iTextSharp.text;using iTextSharp.text.pdf;using iTextSharp.text.pdf.parser;public class ParsingPDF { sta……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2750浏览 524个赞
c#自动识别URL网址的代码using System;using System.Collections.Generic;using System.Text;using System.Net;using System.Text.RegularExpressions;namespace ConsoleApplication3{ clas……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2202浏览 1812个赞
C#提高随机数不重复概率的种子生成方法static int GetRandomSeed( ){ byte[] bytes = new byte[4]; System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Securit……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2897浏览 1428个赞
C#返回多少分钟之前或者之后的时间/** * 获取给定时间的之前某分钟的时间 * 比如现在是:2012-10-10 10:10:10 * 给定的分钟数:50 * 得到的时间为:2012-10-10 9:20:10 * * @return strLateMinutesTime 时间字符 */ public static……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2051浏览 2934个赞
这几天刚整理完Kudy.Net项目中关键词过虑的功能。关键词过虑在网站开发中也算是比较常见的需求了,特别是在SNS社区网站。在网上找的相关文章都达不到我的要求,所以就自己根据过虑的特点专门写了个KeywordFilter,可能满足基本的过虑要求,性能也不错。它有如下特点:一、允许你自定义匹配到关键词时返回的结果,例如匹配到“日你”,你可以在原文中显示例如:“……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1579浏览 375个赞
C#敏感关键词过滤代码 还有待优化的地方 各位有更好的方法 还请分享指点一下 说明原理来源:http://www.cnblogs.com/yujiajun/archive/2012/10/15/keword_Filter.htmlSystem.Text.StringBuilder sb = new System.Text.StringBuilde……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1415浏览 2347个赞
C#监控文件夹并自动给图片文件打水印转自:http://www.cnblogs.com/zhuzhenyu/archive/2012/10/15/2724307.htmlusing System;using System.Collections.Generic;using System.ComponentModel;using System.Da……继续阅读 » 水墨上仙 5年前 (2021-03-12) 3389浏览 1102个赞
C# StreamReader读取文件using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Text;using System.Threading.Tasks;namespace W{ class P……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1674浏览 1338个赞
C# StreamWriter写入文件using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Text;using System.Threading.Tasks;namespace W{ class ……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1548浏览 2701个赞
C#二进制序列化来源:http://blog.csdn.net/mypc2010/article/details/8068963using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Task……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2457浏览 2604个赞
C#修改电脑密码,重置windows密码DirectoryEntry实现转自:http://blog.csdn.net/sufei1013/article/details/8073184 C#修改电脑密码方法如下 /// <summary> /// 更……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1880浏览 1455个赞
C#使用委托实现的快速排序算法class QuickSort { private delegate int CmpOp(object Left, object Right); private void swap(object[] Array, int Left, int Right, CmpOp Cmp) { ……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2080浏览 1928个赞
C#快速排序算法代码演示class Quicksort { private void swap(int[] Array, int Left, int Right) { int temp = Array[Right]; Array[Right] = Array[Left]; ……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2544浏览 138个赞
C# Aggregate and Sum 使用范例using System;using System.Linq;using System.Collections;using System.Collections.Generic;public class MainClass { public static void Main() { ……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2119浏览 2227个赞
C#在数组上使用Aggregateusing System;using System.Collections;using System.Collections.Generic;using System.Text;using System.Linq;public class MainClass { public static void ……继续阅读 » 水墨上仙 5年前 (2021-03-12) 3172浏览 1001个赞
C# Aggregate 用法范例using System;using System.Linq;using System.Collections;using System.Collections.Generic;public class MainClass { public static void Main() { in……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1618浏览 747个赞
此程序包含一个简单的 LINQ to XML 示例查询。它演示了编写 LINQ to XML 查询所需的最少代码。using System;using System.Collections.Generic;using System.IO;using System.Xml;using System.Linq;using System.Xml.L……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2238浏览 2533个赞
示例演示如何创建一个列表类来实现 IEnumerable 和 yield 关键字,以对列表的内容启用 foreach 迭代using System;using System.Collections.Generic;using System.Text;namespace Yield{ class Yield { p……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1583浏览 351个赞
本示例演示如何使用 XML 将代码编入文档// XMLsample.cs// 编译时使用:/doc:XMLsample.xmlusing System;/// <summary>/// 此处显示类级别摘要文档。 </summary>/// <remarks>/// 较长的注释可通过 remarks 标记与……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2762浏览 2574个赞
本示例演示了如何在 C# 中使用 override 和 new 关键字进行版本控制。版本控制有助于在基类和派生类的演变过程中维护它们之间的兼容性。// versioning.cs// 需要 CS0114public class MyBase { public virtual string Meth1() { return……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1529浏览 2532个赞
C#通过指针读取文件// readfile.cs// 编译时使用:/unsafe// 参数:readfile.txt// 使用该程序读并显示文本文件。using System;using System.Runtime.InteropServices;using System.Text;class FileReader{ const u……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1343浏览 2254个赞
本示例演示如何定义与类或结构之间的转换,以及如何使用此类转换// conversion.csusing System;struct RomanNumeral{ public RomanNumeral(int value) { this.value = value; } // 声明从 int 到 ……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2646浏览 2769个赞
本示例演示了如何在 C# 中使用非托管代码(使用指针的代码)。// printversion.cs// 编译时使用:/unsafeusing System;using System.Reflection;using System.Runtime.InteropServices;// 为此程序集指定一个版本号:[assembly:Assemb……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2790浏览 1683个赞
C# 通过指针实现的fastcopy,快速拷贝函数// fastcopy.cs// 编译时使用:/unsafeusing System;class Test{ // unsafe 关键字允许在下列 // 方法中使用指针: static unsafe void Copy(byte[] src, int srcIndex,……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1439浏览 1014个赞
本示例演示了下面的线程处理技术。创建、启动和终止线程使用线程池线程同步和互交 ThreadPool.csusing System;using System.Threading;// Fibonacci 类为使用辅助// 线程执行长时间的 Fibonacci(N) 计算提供了一……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2710浏览 1369个赞
本示例演示结构的语法和用法。它还介绍了类与结构之间的重大差异 // struct1.csusing System;struct SimpleStruct{ private int xval; public int X { ……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2585浏览 1563个赞
本示例演示了如何通过权限类和权限属性来修改安全权限 // ImperativeSecurity.csusing System;using System.Security;using System.Security.Permissions;using Syst……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2281浏览 142个赞
C#类和属性的使用 abstractshape.cs// abstractshape.cs// 编译时使用:/target:library// csc /target:library abstractshape.csusing System;public abstract ……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1514浏览 172个赞
本示例演示属性为何是 C# 编程语言必不可少的一个组成部分。它演示了如何声明和使用属性// person.csusing System;class Person{ private string myName ="N/A"; private int myAge = 0; // 声明 string 类型的 ……继续阅读 » 水墨上仙 5年前 (2021-03-12) 3215浏览 1561个赞
本示例演示了如何使用允许在两个或更多 C# 文件中定义类或结构的分部类型。这就允许多个程序员并行处理一个类的不同部分,并将复杂类的不同方面保存在不同的文件中。 CharTypesPrivate.csusing System;using System.Collections.Gen……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1905浏览 2883个赞
本示例演示了用户定义的类如何能够重载运算符// complex.csusing System;public struct Complex { public int real; public int imaginary; public Complex(int real, int imaginary) { thi……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2832浏览 1454个赞
本示例演示了如何在 C# 中使用 Microsoft Access 数据库。它演示了如何创建数据集并从数据库向该数据集添加表。// OleDbSample.cs// 若要从命令行生成此示例,请使用命令:// csc oledbsample.csusing System;using System.Data;using System.Data.O……继续阅读 » 水墨上仙 5年前 (2021-03-12) 3064浏览 2264个赞
C#统计字符串中数字的个数// DigitCounter.cs// 编译时使用:/target:libraryusing System; // 声明与 Factorial.cs 中的命名空间相同的命名空间。这样仅允许将 // 类型添加到同一个命名空间中。namespace Functions { public class Digit……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2092浏览 222个赞