C#.NET 中的类型转换 2006-3-16 575 · C#.NET 中的类型转换边城狂人=================== C# 出来也有些日子了,最近由于编程的需要,对 C# 的类型转换做了一些研究,其内容涉及 C# 的装箱/拆箱/别名、数值类型间相互转换、字符的 ASCII 码和 Unicode 码、数值字符串和数值之间的转换、字符串和字符数组/字节数组之间的转换、各种数 ...
C#常用函数和方法集汇总 2006-2-24 1073 · 1、DateTime 数字型 System.DateTime currentTime=new System.DateTime(); 1.1 取当前年月日时分秒 currentTime=System.DateTime.Now; 1.2 取当前年 int 年=currentTime.Year; 1.3 取当前月 int 月=currentTime.Month; 1.4 取当前日 int 日=currentTime.Day; 1.5 取当前时 int...
如何将枚举绑定到DropDownList上 2006-4-6 16 · <HTML> <HEAD> <title>WebForm5</title> <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"> <meta content="C#" name="CODE_LANGUAGE"> <meta content="...
用C#快速往Excel写数据 2006-3-16 67 · 示例是用于将ListView中的内容倒入到Excel与常用的逐单元格写不同的是,本例子采用数据写入到range的方法。该方法效率明显较高Excel.Application app = new Excel.ApplicationClass(); if( app == null) { MessageBox.Show("Excel无法启动"); return; } app.Visible = tru...
文件的一些基本操作 2006-3-16 60 · using System;using System.IO;using System.Text;namespace Document.Bll{ /**//// <summary> /// Summary description for fileinfo. /// </summary> public class fileinfo { public fileinfo() { // // TODO: Add constructor...
如何将数据从c#导出到excel表 2006-3-16 80 · public void CreateExcel(DataSet ds,string typeid,string FileName) { HttpResponse resp; resp = Page.Response; resp.ContentEncoding = ...
C#函数实现的小功能集合 2006-3-16 104 · ==================子窗体返回主窗体 /**////<summary> ///名称:redirect ///功能:子窗体返回主窗体 ///参数:url ///返回值:空 ///</summary> public void redirect(string url,Page page) { if ( Session["IfDefault"]!=(object)"Def...
一个拷贝整个文件夹(包括子文件夹)的方法 2006-3-16 64 · 需要引用命名空间:using System.IO;/// <summary> /// 拷贝文件夹(包括子文件夹)到指定文件夹下,源文件夹和目标文件夹均需绝对路径. 格式: CopyFolder(源文件夹,目标文件夹); /// </summary> /// <param name="strFromPath"></param> /// <param name=&...
ASP.NET(c#)运用API函数获取系统信息 2006-3-16 46 · 在Visual C#中调用API的基本过程: 首先,在调用API之前,你必须先导入System.Runtime.InteropServices这个名称空间。该名称空间包含了在Visual C#中调用API的一些必要集合,具体的方法如下: using System.Runtime.InteropServices; 在导入了名称空间后,我们要声明在程序中 ...
如何通过一个图片的URL得到该图片的尺寸大小? 2006-3-16 49 · 因为在获取网络上的图片大小或数据时,如果不断地形成临时文件,再打开,这个过程不仅速度比较慢,而且给人的感觉总有些不爽,当然不失一种解决办法。一般的期望就是在内存中完成所有操作,幸好我们可出使用MemoryStream,通过它我们可以比较轻松地达到目的。 1private void button2_Click(object ...
c#学习体会:使用 ref 和 out 传递数组 2006-3-16 58 · c#学习体会:使用 ref 和 out 传递数组(downmoon),希望与大家分享1、与所有的 out 参数一样,在使用数组类型的 out 参数前必须先为其赋值,即必须由接受方为其赋值。例如:public static void MyMethod(out int[] arr) { arr = new int[10]; // 数组arr的明确委派}2、与所有的 ref 参数一样,...
C#快速排序类 2006-3-16 35 · 快速排序的基本思想是基于分治策略的。对于输入的子序列ap..ar,如果规模足够小则直接进行排序,否则分三步处理: 分解(Divide):将输入的序列ap..ar划分成两个非空子序列ap..aq和aq+1..ar,使ap..aq中任一元素的值不大于aq+1..ar中任一元素的值。 递归求解(Conquer):通过递归对p..aq和aq+1..ar ...
C#中利用SharpZipLib进行文件的压缩和解压缩 2006-3-16 31 · 在做项目的时候需要将文件进行压缩和解压缩,于是就从http://www.icsharpcode.net下载了关于压缩和解压缩的源码,但是下载下来后,面对这么多的代码,一时不知如何下手。只好耐下心来,慢慢的研究,总算找到了门路。针对自己的需要改写了文件压缩和解压缩的两个类,分别为ZipClass和UnZipClass。其...
批量字符串替换程序-2 2006-3-16 18 · (3)批量替换。我最先采用Hashtable实现,测试结果发现性能比较低,然后就直接改用数组实现,写一个hash函数,将待换字符串hash到数组。flexIndex是松弛系数。 1 public class StringBatchFilter:StringFilter 2 { 3 private int width=0; 4 const int flexIndex = 10; ...
批量字符串替换程序-1 2006-3-16 33 · (1)PairString 1 public struct PairString 2 { 3 public string OldValue; 4 public string NewValue; 5 public bool IsRightFilter; 6 public bool IsLeftFilter; 7 8 public PairString(string oldValue, string newValue) 9 {10 ...
计算俩个时间之间隔多少月 2006-3-16 27 · using System;class Test{ static int MonthsDiff(DateTime dt1, DateTime dt2) { int m = (dt2 - dt1).Days / 31; while (dt1.AddMonths(m) < dt2) m++; return m; } static void Main() { DateTime dt1 = new DateTime(2005, 1, 1); DateTime dt2 = new DateTime(20...
C#调用父类的父类的方法 2006-3-16 33 · override一个C#函数时,如果想调用这个函数在父类的父类中相应的方法,可以将override关键字变成new,调用时将Object转义成父类的父类class A{public virtual void Func(){Console.WriteLine("A");}}class B:A{public new void Func(){Console.WriteLine("B");}}class C:B{publ...
页次:1 /1 20篇/页 首页 上一页 下一页 尾页 合计 17 篇 Go:第1页