falla.zhang

导航

随笔分类 -  C#

C# 3.0 扩展方法&接口
摘要:namespace ExtensionInterfaceMethod{ class Program { static void Main(string[] args) { //使用接口变量来调用扩展方法 IBasicInterface bii = new BasicImplement(); bii.SubStract(9, 3); } } //先创建一个简单的接口 public interface... 阅读全文

posted @ 2010-02-23 16:16 falla.zhang 阅读(876) 评论(0) 推荐(0)

C# 3.0 扩展方法
摘要:扩展方法解决问题:以往对已存在的类库进行扩展,可行的方式直接对源代码进行修改或者直接派生。 扩展方法注意事项: 扩展方法必须被定义在一个静态类中,扩展方法自身必须是一个静态方法; 扩展方法中的首个参数必须是this,最后紧跟要扩展的类的名称; 扩展方法可以被对象实例调用,也可以使用静态类名进行静态调用。 扩展方法的使用范围: 实例调用: namespace ExtensionMethodOb... 阅读全文

posted @ 2010-02-23 15:56 falla.zhang 阅读(413) 评论(0) 推荐(0)

C# 启动欢迎界面
摘要:第一步: 主程序启动主窗体(这里表示为 form1)如下: static class Program { /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibl... 阅读全文

posted @ 2010-02-22 17:08 falla.zhang 阅读(2777) 评论(0) 推荐(0)

C#XML
摘要:XmlTextWriter xmlWriter; string strFilename = Server.MapPath( "data1.xml") ; xmlWriter = new XmlTextWriter(strFilename,Encoding.Default);//创建一个xml文档 xmlWriter.Formatting = Formatting.Indented; xmlWrit... 阅读全文

posted @ 2010-02-08 13:13 falla.zhang 阅读(225) 评论(0) 推荐(0)

C#MD5
摘要:using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Drawing;using System.Web;using System.Web.SessionState;using System.Web.UI;using System.Web.UI.WebContr... 阅读全文

posted @ 2010-02-08 13:13 falla.zhang 阅读(200) 评论(0) 推荐(0)

C#string
摘要:C#的String.Split 方法 程序代码 1) public string[] Split(params char[] separator)2) public string[] Split(char[] separator, int count)3) public string[] Split(char[] separator, StringSplitOptions options)4) p... 阅读全文

posted @ 2010-02-08 13:12 falla.zhang 阅读(671) 评论(0) 推荐(0)

C#Application.DoEvents()
摘要:/// <summary>/// 颜色变化反差形成视觉闪烁效果/// </summary>private void button1_Click(object sender, EventArgs e){ //Visible控件属性 while (Visible) { for (int rgb = 0; rgb < 254 && Visible; rgb+... 阅读全文

posted @ 2010-02-03 11:42 falla.zhang 阅读(7868) 评论(0) 推荐(0)

C#与.NET 3.0高级程序设计读书笔记
摘要:转自网络 第三章:一:main带的参数可以直接访问args数组,也可以通过Environment类的静态函数GetCommandLineArgs获得。Environment类还包含其他有关应用程序和操作系统的有关信息。二:类必须在new之后才能用,c#不会将类类型分配到栈上三:之用定义构造函数,无需定义析构函数,因为c#有垃圾自动收集机制四:有关“分工:(separation of c... 阅读全文

posted @ 2010-02-01 16:45 falla.zhang 阅读(399) 评论(0) 推荐(0)

C#程序设计读书笔记
摘要:第一章 基础 一个 计算机程序就像时一架壮观的机器,当这架机器里的齿轮、杠杆和活塞运转起来的时候,整个房间就将充满着华丽复杂而又美妙动听的音里。我们将看到变化着的逻辑、运动着的算法和舞蹈着的数据.。 1. C#区分大小写。 变量名必须以一个字母或者下划线字符开头;变量名只能由字母、下划线字符和数字组成。 当一个 C#程序运行时,其中的声明语句将使一小块内存被专门拿出来存放有关变量的值。把这一过程称... 阅读全文

posted @ 2010-02-01 16:37 falla.zhang 阅读(693) 评论(0) 推荐(0)

C#中SQL语句参数写法
摘要:OracleConnection oc=new OracleConnection("data source=osserver;User Id=****;password=**");OracleCommand cmd=new OracleCommand("insert into cym1.uploadfile (filename,filecontent) values (:filename,:fil... 阅读全文

posted @ 2010-02-01 16:24 falla.zhang 阅读(525) 评论(0) 推荐(1)

C#利用using和try-finally来释放资源
摘要:转载自:http://blog.csdn.net/goga21cn/archive/2007/08/25/1758269.aspx很明显,Dispose方法是一个外部方法,系统并不会帮你调用。为了尽早释放对象所占用的资源,所以需要保证Dispose方法能尽早被执行。那么在.Net中提供了一个比较简便的方法,就是对于实现了IDisposable接口的类型对象提供了using语句。就操作一个数据库这个... 阅读全文

posted @ 2010-02-01 10:51 falla.zhang 阅读(1919) 评论(0) 推荐(0)

C#Application:Exit与ExitThread
摘要:转载: http://blog.sina.com.cn/kenliveme Application.Exit(); 方法停止在所有线程上运行的所有消息循环,并关闭应用程序的所有窗口 Application.ExitThread 方法 退出当前线程上的消息循环,并关闭该线程上的所有窗口。 这几天在做一个把大量Infopath生成的XML数据,进行处理的程序,我用了MDI子窗体,每个窗体包含了各自的... 阅读全文

posted @ 2010-01-29 17:32 falla.zhang 阅读(4564) 评论(0) 推荐(2)

C#Random
摘要:c# Random快速连续产生相同随机数的解决方案 Random类是一个产生伪随机数字的类,它的构造函数有两种,一个是直接New Random(),另外一个是New Random(Int32),前者是根据触发那刻的系统时间做为种子,来产生一个随机数字,后者可以自己设定触发的种子,一般都是用UnCheck((Int)DateTime.Now.Ticks)做为参数种子,因此如果计算机运行速度很快,如果... 阅读全文

posted @ 2010-01-29 17:29 falla.zhang 阅读(39477) 评论(6) 推荐(5)

C#生成DLL文件
摘要:使用csc命令将.cs文件编译成.dll的过程 很多时候,我们需要将.cs文件单独编译成.dll文件, 操作如下: 打开命令窗口->输入cmd到控制台->cd C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 转到vs.net安装的该目录下->执行csc命令csc /target:library File.cs->在该目录下产生一个对... 阅读全文

posted @ 2010-01-29 17:23 falla.zhang 阅读(25014) 评论(2) 推荐(1)

C# 将小写数字转换为 一般中文大写数字 和 人民币大写数字
摘要:网络转载 class DigitToChnText{ private readonly char[] chnGenText; private readonly char[] chnGenDigit; private readonly char[] chnRMBText; private readonly char[] chnRMBDigit; private readonly char[] chn... 阅读全文

posted @ 2010-01-29 17:22 falla.zhang 阅读(5373) 评论(0) 推荐(2)

C#实现程序启动唯一实例的一种方法
摘要:private static void GetSingleThread() { string name = Process.GetCurrentProcess().ProcessName; int id = Process.GetCurrentProcess().Id; Process[] nProcess = Process.GetProcesses(); foreach(Process ... 阅读全文

posted @ 2010-01-29 17:20 falla.zhang 阅读(547) 评论(0) 推荐(0)