随笔分类 -  C#

摘要:.Net提供了一个叫Lazy<T>的对象,可以让我们很方便的延时创建大型或消耗资源的对象,可以很好的提高应用程序的性能。static void Main(string[] args){ Lazy<TestLazy> lazy = new Lazy<TestLazy>(); //封装要延时加载的对象 Console.WriteLine("创建Lazy对象"); Console.WriteLine("是否创建对象:" + lazy.IsValueCreated); lazy.Value.Execute(); //调用对象中 阅读全文
posted @ 2012-12-20 13:34 要等闲阿 阅读(201) 评论(0) 推荐(0)
摘要:方法:/// <summary> /// 将字符串转换成Color类型 /// </summary> /// <param name="color"></param> /// <returns></returns> public static Color ReturnColorFromString(string color) { color = color.Substring(1, color.Length-1); string alpha = color.Subst... 阅读全文
posted @ 2012-09-27 14:12 要等闲阿 阅读(1174) 评论(0) 推荐(0)
只有注册用户登录后才能阅读该文。
posted @ 2012-07-30 23:00 要等闲阿 阅读(31) 评论(0) 推荐(0)
只有注册用户登录后才能阅读该文。
posted @ 2012-07-27 15:56 要等闲阿 阅读(1) 评论(0) 推荐(0)
只有注册用户登录后才能阅读该文。
posted @ 2012-07-19 15:26 要等闲阿 阅读(2) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2012-07-17 22:18 要等闲阿 阅读(3) 评论(0) 推荐(0)
摘要://今天DateTime.Now.Date.ToShortDateString();//昨天,就是今天的日期减一DateTime.Now.AddDays(-1).ToShortDateString();//明天,同理,加一DateTime.Now.AddDays(1).ToShortDateString();//本周(要知道本周的第一天就得先知道今天是星期几,从而得知本周的第一天就是几天前的那一天,要注意的是这里的每一周是从周日始至周六止DateTime.Now.AddDays(Convert.ToDouble((0 - Convert.ToInt16(DateTime.Now.DayOfWe 阅读全文
posted @ 2012-07-11 17:50 要等闲阿 阅读(220) 评论(0) 推荐(0)
摘要:日期:/// <summary> /// 判断两个日期是否在同一周 /// </summary> /// <param name="dtmS">开始日期</param> /// <param name="dtmE">结束日期</param> /// <returns></returns> private bool IsInSameWeek(DateTime dtmS, DateTime dtmE) { TimeSpan ts = dtmE - dtmS; .. 阅读全文
posted @ 2012-07-11 16:31 要等闲阿 阅读(4190) 评论(0) 推荐(0)
摘要:dynamic cmd = AutomationFactory.CreateObject("WScript.Shell"); cmd.Run("calc.exe", 1, true); 阅读全文
posted @ 2012-07-04 11:36 要等闲阿 阅读(193) 评论(0) 推荐(0)
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using MSWord = Microsoft.Office.Interop.Word;using System.IO;using System.Reflection;namespace CreateWordXDemo{ class Program { static void Main(string[] args) { object ... 阅读全文
posted @ 2012-07-02 14:54 要等闲阿 阅读(799) 评论(0) 推荐(0)
摘要:DateTime d1 = DateTime.Parse("2012-3-10 10:30"); DateTime d2 = DateTime.Parse("2012-4-9 10:30"); System.TimeSpan nd = d2 - d1; int num = nd.Minutes; double num2 = nd.TotalMinutes; Console.WriteLine(num.ToString()); Console.WriteLine(n... 阅读全文
posted @ 2012-07-02 14:10 要等闲阿 阅读(120) 评论(0) 推荐(0)
摘要:第一种方法:DateTime d = new DateTime(2009, 2, 8); System.Globalization.Calendar c = new System.Globalization.GregorianCalendar(); int daysInAugust = c.GetDaysInMonth(d.Year, d.Month); // 31 MessageBox.Show(daysInAugust.ToString());第二种方法:public int GetDays(int year, int m... 阅读全文
posted @ 2012-06-26 10:09 要等闲阿 阅读(537) 评论(1) 推荐(0)
摘要:public static string CaculateWeekDay(int y, int m, int d) //年月日换算成星期几 { if (m == 1) m = 13; if (m == 2) m = 14; int week = (d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400) % 7 + 1; string weekstr = ""; switch (week)... 阅读全文
posted @ 2012-06-25 15:37 要等闲阿 阅读(864) 评论(0) 推荐(0)