文章分类 - C#
摘要:1.定义属性类using System;public class PropertyAttribute:Attribute{ public string _tableName; public int _date; public PropertyAttribute(string tableName) { this._tableName = tableName; } public PropertyAtt...
阅读全文
摘要:比如说到dataset.从网上看到一些关于性能优化的文章 1、 利用索引加快查找行的效率 如果需要反复查找行,建议增加索引。有两种方式: 1)设置DataTable的PrimaryKey 适用于按PrimaryKey查找行的情况。注意此时应调用DataTable.Rows.Find方法,一般惯用的Select方法不能利用索引。 2)使用DataView 适用于按Non-PrimaryKey查找行的...
阅读全文
摘要:当前程序所在的文件夹 System.IO.Directory.GetCurrentDirectory() 显示指定文件夹下的文件 if(this.textBox1.Text.Trim()=="") return;this.listBox1.Items.Clear();string[] MyFiles=System.IO.Directory.GetFiles(this.textBox...
阅读全文
摘要:string str = "源字符串"; str = Regex.Replace(str, "(hello|hi|nihao|welcome|chilema)", "Comment vas-tu ", RegexOptions.IgnoreCase);
阅读全文
摘要:using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.W...
阅读全文
摘要:using System; using System.Collections.Generic; namespace DomainBase { public class ObjectCache { //Dictionary 会自动维护一个空链表来保存不用的单元。 //这里,使用被缓存对象的“弱引用”,允许这些对象被垃圾回收。 pri...
阅读全文
摘要:利用设计模式可以使我们的代码更灵活,更容易扩展,更容易维护。各种面向对象的程序设计语言都提供了基本相同的机制:比如类、继承、派生、多态等等。但是又有各自的特色,c# 中的反射机制便是一个很重要的工具,好好地利用就可以在实际中发挥很大的作用。 例子: using System; namespace Factory { public interface IFruit { ...
阅读全文
摘要:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->using System; using System.Data; using System.Configuration; using System.Collections; using System.We...
阅读全文
摘要:1using System; 2using System.Collections.Generic; 3using System.Text; 4 5namespace CW 6{ 7 public class Cash 8 { 9 private static string MoneyNum = "零一二三四五六七八九"; 10 private...
阅读全文
摘要:File类和FileInfo类 C#语言中通过File和FileInfo类来创建、复制、删除、移动和打开文件。在File类中提供了一些静态方法,使用这些方法可以完成上述功能,但File类不能建立对象。FileInfo类使用方法和File类基本相同,但FileInfo类能建立对象。在使用这两个类时需要引用Syst...
阅读全文
摘要:业务需求: 现在需要设计一个银行支付(服务)系统,集成中国和美国两家银行的支付(服务)方式. 业务方法: 存钱(Save),取钱(Get),汇款(Post) 下面通过抽象工厂的模式实现以上需求: (1). 定义业务方法接口(或者抽象类) 银行业务接口 Code highlighting produced by Actipro CodeHighlighter (freeware)http://w...
阅读全文
摘要:最近学习设计模式,对于抽象工厂很是难以理解,就到网上查看一番,碰到一哥们写的文章,比喻很贴切,也算是让我明白了大概。下面是转载他写的文章。 一直觉得设计模式是非常抽象的(事实上MS也是。。。),所以就想把它说的白话点儿,让人更容易理解。 关于抽象工厂(Abstract Factory)模式,网上一个非常流行的例子,麦当劳和肯德基的故事。具体怎么说的我已经忘了,但是我想自己...
阅读全文
摘要:引用来自: http://www.microsoft.com/china/msdn/archives/library/dndotnet/html/objserializ.asp 目录 简介 持久存储 ...
阅读全文
摘要:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->/// /// 备份数据库 /// /// 源数据库绝对路径 /// 目标数据库绝对路径 /// public void backup_db(string mdb1, string ...
阅读全文


浙公网安备 33010602011771号