上一页 1 2 3 4 5 6 ··· 15 下一页
摘要: 假设有A、B两个类,他们的成员完全相同,在给对象A设完值后,想让对象B也像A一样,有设置过的值,此时可用ValueInjecter来解决。代码:using System;using System.Collections.Generic;using System.Text;using Omu.Valu... 阅读全文
posted @ 2014-05-22 21:34 哲夫 阅读(190) 评论(0) 推荐(0) 编辑
摘要: class Program { delegate bool Foo(int n); static bool foo1(int n) { return true; } static bool foo2(int n) { return n... 阅读全文
posted @ 2014-05-14 17:03 哲夫 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 看了官方的、网上其他的,写了2个demo,只不过还是没发现哪里会用到。IEnumerable和IEnumerator都是System.Collections下的接口,结构分别如下:namespace System.Collections{ public interface IEnumerabl... 阅读全文
posted @ 2014-05-13 17:38 哲夫 阅读(125) 评论(0) 推荐(0) 编辑
摘要: static void Main(string[] args) { //输出:2 4 8 16 32 64 128 256 foreach (int i in Power(2, 8)) { ... 阅读全文
posted @ 2014-05-13 11:02 哲夫 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 一、System.Timers.Timer并不是调用Start方法就执行,而是在过了设定的周期再调用Start才执行(System.Windows.Forms.Timer也一样)。获取或设置一个值,该值指示 Timer 是应在每次指定的间隔结束时引发 Elapsed 事件,还是仅在指定的间隔第一次结... 阅读全文
posted @ 2014-05-12 03:45 哲夫 阅读(118) 评论(0) 推荐(0) 编辑
摘要: #region 调用timer控件实时查询开关机时间private void timer1_Tick(object sender, EventArgs e){ string sql = "SELECT startTime,endTime,AMTusername,AMTpassword,AMTi... 阅读全文
posted @ 2014-05-12 03:03 哲夫 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 在C#中记录日志时,为了以后查找错误或者跟踪的方便,最好能记录下出错的源代码的文件名和出错的源代码的行数。这2个方法如下:/// /// 取得当前源码的哪一行/// /// public static int GetLineNum(){ System.Diagnostics.StackTrac... 阅读全文
posted @ 2014-04-20 18:04 哲夫 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 最近搞一个系统时由于在比较关键地方用到反射了,所以要关注了一下反射的性能问题。搜索一下,不难搜到老赵的这篇文章,下面是一些杂乱的笔记。(建议先看老赵的文章).Net4.0反射性能改善看老赵的文章,老赵得到的结果是这样的:12300:00:00.0125539 (Directly invoke)00:... 阅读全文
posted @ 2014-02-20 10:34 哲夫 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 逆变(contravariant)与协变(covariant)是C#4新增的概念,许多书籍和博客都有讲解,我觉得都没有把它们讲清楚,搞明白了它们,可以更准确地去定义泛型委托和接口,这里我尝试画图详细解析逆变与协变。变的概念我们都知道.Net里或者说在OO的世界里,可以安全地把子类的引用赋给父类引用,... 阅读全文
posted @ 2014-02-19 10:55 哲夫 阅读(144) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Management;using Microsoft.Win32;using Microsoft.Visual... 阅读全文
posted @ 2014-02-18 14:13 哲夫 阅读(122) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 15 下一页