c#
文章平均质量分 82
江林子
小小程序员软件工程师
展开
-
使用for循环打印ASCII表
static void Main(string[] args) { Console.WriteLine("请输入您要打印的行数:"); int num = Convert.ToInt32(Console.ReadLine()); int ascii; for (int i = 0; i原创 2013-03-29 17:31:41 · 2812 阅读 · 0 评论 -
正则表达式30分钟入门教程
目录本文目标如何使用本教程正则表达式到底是什么东西?入门测试正则表达式元字符字符转义重复字符类分枝条件反义分组后向引用零宽断言负向零宽断言注释贪婪与懒惰处理选项平衡组/递归匹配还有些什么东西没提到联系作者网上的资源及本文参考文献更新纪录本文目标30分钟内让你明白正则表达式是什么,并对它有一些转载 2014-03-11 15:04:26 · 451 阅读 · 0 评论 -
用C#语言解压Html源码
/// /// 解压html /// /// 传入url地址 /// 返回解压好的html源码 public string GetWebUrlData(string Url) { HttpWebRequest request = null;原创 2014-04-15 15:04:20 · 597 阅读 · 0 评论 -
获取时间毫秒数
string HtmlAll = GetWebUrlData(url).Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace(" ", "");原创 2014-04-15 17:39:45 · 655 阅读 · 0 评论 -
文件流操作--将一个文件复制到另外一个地方
class Program { static void Main(string[] args) { //源 string source = @"C:\Users\Steve\Desktop\搞笑资料\疯狂的足球1.rmvb"; //目标 string targe原创 2016-03-01 19:25:28 · 1132 阅读 · 0 评论 -
.net 自带的两个内置委托
#region Action与Func内置委托 //--------------无返回值的委托--------------------------- //1.无参数,无返回值的委托 Action action = () => { Console.WriteLine("无参数,没有返回值!"); };原创 2016-03-01 19:35:34 · 1225 阅读 · 0 评论 -
进程操作
//获取当前电脑上的所有进程 Process[] ps = Process.GetProcesses(); Console.WriteLine(ps.Length); for (int i = 0; i < ps.Length; i++) { //打印所有进程名称原创 2016-03-01 21:13:33 · 466 阅读 · 0 评论 -
线程的基本操作
namespace 线程的操作演示{ class Program { static void Main(string[] args) { //1.通过启动一个新线程执行一个无参数,无返回值的方法 Thread t = new Thread(new ThreadStart(M1));原创 2016-03-01 21:17:40 · 531 阅读 · 0 评论 -
有进度条的拷贝文件,异步
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.IO;using System.Linq;using System.Text;using System.Threading;usi原创 2016-03-09 21:17:09 · 647 阅读 · 0 评论 -
摇奖机-多线程
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading;using System.Threadi原创 2016-03-10 18:24:32 · 811 阅读 · 0 评论 -
简单的DBHelper类
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Configuration;using System.Data.SqlClient;using System.Data;namespace GoldenUnicornDAL{ public原创 2016-04-11 21:49:33 · 1250 阅读 · 1 评论 -
写日志文件
#region 写日志文件 /// /// 写日志文件 /// /// 要记录的内容字符串 public static void WriteLogFile(string input) { //指定日志文件的目录 string fname = Direc原创 2016-05-16 14:10:21 · 484 阅读 · 0 评论 -
Aspose.Cells生成Excel 服务器不用安装office
Aspose.Cells生成Excel 服务器不用安装office原创 2016-06-24 17:47:07 · 955 阅读 · 0 评论 -
C#实用函数大全
using System;using System.Collections.Generic;using System.Text;using Microsoft.Win32; //对注册表操作using System.Collections; //使用Arraylistusing System.Security.Cryptography;//加密解密using System.IO;转载 2013-12-17 12:53:43 · 2141 阅读 · 0 评论 -
添加项目服务
一、初始化运行:InstallUtil.exeInstallUtil.exe路径:C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe1)打开cmd2)输入路径:cd C:\Windows\Microsoft.NET\Framework\v4.0.30319 然后回车3)输入程序名:InstallUti原创 2013-11-09 10:29:26 · 944 阅读 · 0 评论 -
使用while、do-while、for打印九九乘法表、三角形和冒泡排序
//用while打印九九乘法表: int i = 1; while (i <= 9) { int j = 1; while (j <= i) { float result = j * i;原创 2013-03-29 17:12:17 · 7293 阅读 · 0 评论 -
随机产生六个不相等的整数放进数组中,然后循环输出
static void Main(string[] args) { //随机产生六个不相等的整数,然后循环输出 //方法一: Random ran = new Random(); int[] num = new int[6]; int原创 2013-03-29 18:46:23 · 941 阅读 · 0 评论 -
数组进行增、删、查、改
class Program { private static int[] num = new int[0];//定义一个数组 /// 封装num数字字段 ///封装num数字字段 /// public int[] Num { get {原创 2013-04-10 20:28:05 · 684 阅读 · 0 评论 -
使用NPOI操作Excel导入导出数据
使用NPOI的优势:1、你不需要在服务器上安装微软的Office,可以避免版权问题。2、使用起来比Office PIA的API更加方便,更人性化。3、你不用去花大力气维护NPOI,NPOI Team会不断更新、改善NPOI,绝对省成本。NPOI之所以强大,并不是因为它支持导出Excel,而是因为它支持导入Excel,并能“理解”OLE2文档结构,这也是其他一些Exc原创 2013-07-14 03:11:47 · 1515 阅读 · 3 评论 -
使用正则表达式截取字符串显示内容长度
#region 使用正则表达式截取字符串显示内容长度 /// /// 使用正则表达式截取字符串显示内容长度 /// /// 要切取的字符串 /// 要得到的长度 /// 切取后的字符串 public static string CutString2(object content, int length) { str原创 2013-07-16 21:25:05 · 2882 阅读 · 0 评论 -
反转一维数组的部分元素的元素顺序
namespace //反转一维数组的部分元素的元素顺序{ class Program { static void Main(string[] args) { int []b=new int[]{1,2,43,11,23,56,67};//要反转的数组 int []a= Reverse(b,2,6)原创 2013-07-17 14:13:41 · 1039 阅读 · 0 评论 -
委托和事件
委托: //一、委托: //委托实际上是一个能够持有对某个方法引用的类。实现一个委托的过程大致如下: //(1).声明一个delegate对象,它与你想要传递的方法具有相同参数和返回值类型。 //(2).定义一个delegate对象,并将你想要传递的方法作为参数传入。 //(3).通过上一步创建的delegate对象来调用方法。 class Pr原创 2013-07-27 11:54:19 · 470 阅读 · 0 评论 -
开发扩展的文本框控件
带正则表达式的文本框控件:JS代码:function checkNoZeroInteger(textbox, valType) { if (valType == "正整数") { var reg = /^\+?[1-9][0-9]*$/; //验证非零整数的正则表达式 if (!reg.exec(textbox.value)) {//验证不通过原创 2013-07-25 22:21:18 · 532 阅读 · 0 评论 -
使用C#语言对XML文件进行增、删、改、查
XML:Extensible Markup Language(可扩展标记语言)的缩写,是用来定义其它语言的一种元语言,其前身是SGML(Standard Generalized Markup Language,标准通用标记语言)。它没有标签集(tag set),也没有语法规则(grammatical rule),但是它有句法规则(syntax rule)。 任何XML文档对任原创 2013-08-04 15:56:27 · 923 阅读 · 0 评论 -
C#语言读写TXT文本文件
注:1)读写文本文件需要引用IO命名空间 2)读txt文件需要OpenFileDialog控件using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using Sy原创 2013-08-04 16:43:47 · 1029 阅读 · 0 评论 -
使用C#语言进行序列化和反序列化
需要序列化和反序列化时:1)在需要序列化的类顶部加上[Serializable]特性; 2)引用using System.Runtime.Serialization.Formatters.Binary;namespace MySerializable{ [Serializable] public class Student {原创 2013-08-04 17:33:49 · 500 阅读 · 0 评论 -
多线程
使用多线程的步骤:1、引用命名空间:using System.Threading;2、编写好需要多线程执行的方法;3、声明一个线程并传入一个需要执行方法;4、调用线程的Start()方法标志可以执行;具体代码如下:using System;using System.Collections.Generic;using System.ComponentModel;原创 2013-08-11 19:48:37 · 439 阅读 · 0 评论 -
Socket编程
以下模拟聊天程序进行Socket编程服务器端代码:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using Syste原创 2013-08-11 19:57:41 · 514 阅读 · 0 评论 -
微信长连接转短连接
/// /// 微信长链接转短链接 /// /// public string GetShortUrl() { //参数 是否必须 说明 //access_token 是 调用接原创 2017-12-05 12:00:30 · 3831 阅读 · 0 评论