随笔分类 - C#_通用方法
摘要:源:http://blog.csdn.net/xuzhiqiang1010/article/details/4987824看看以下会不会产生死锁:public class A { private object obj = new object(); public void Test(int i) { lock (obj) { if (i>10) { i--; Test(i); } else { Console.WriteLine(i); } } } } class Program { static void Main(string[] args) { A a = new A(); a.T
阅读全文
摘要:编辑器加载中... //月份天数 int iMonthDay=DateTime.DaysInMonth(int.Parse(sYear),int.Parse(sMonth));
阅读全文
摘要:一般来说我们都是用 Hashtable 的 ContainsKey 方法来查找 Hashtable 中是否存在某个键值然后读取他,但是这个方法并不是效率最好的方法。比较好的方法是直接读取键值然后判断这个对象是否为 null 然后读取。两种代码分别如下:一般慢速的方法:if(objHash.ContainsKey(keyValue)) { strValue=(String)objHash[keyValue]; }而快速的方法是:ObjectobjValue=objHash[keyValue]; if (objValue!=null) { strValue=(String)objValue; }
阅读全文

浙公网安备 33010602011771号