C#时间函数扩展
//本周是本年第几周private int DatePart(System.DateTime dt) { int weeknow = Convert.ToInt32(dt.DayOfWeek);//今天星期几 int daydiff = (-1) * (weeknow+1);//今日与上周末的天数差 int days = System.DateTime.Now.AddDays(daydiff).DayOfYear;//上周末是本年第几天 int weeks = days/7; if(days%7 != 0) { weeks++; } //此时,weeks为上周是本年的第几周 return (weeks+1); } //本周起止日期 private string WeekRange(System.DateTime dt) { int weeknow = Convert.ToInt32(dt.DayOfWeek); int dayd
DateTime 数字型
System.DateTime currentTime=new System.DateTime();1.1 取当前年月日时分秒 currentTime=System.DateTime.Now; 1.2 取当前年 int 年=currentTime.Year; 1.3 取当前月 int 月=currentTime.Month; 1.4 取当前日 int 日=currentTime.Day; 1.5 取当前时 int 时=currentTime.Hour; 1.6 取当前分 int 分=currentTime.Minute; 1.7 取当前秒 int 秒=currentTime.Second; 1.8 取当前毫秒 int 毫秒=currentTime.Millisecond; (变量可用中文) 1.9 取中文日期显示——年月日时分 string strY=currentTime.ToString("f"); //不显示秒 1
ArrayList用法
System.Collections.ArrayList类是一个特殊的数组。通过添加和删除元素,就可以动态改变数组的长度。[@more@]一.优点 1。支持自动改变大小的功能 2。可以灵活的插入元素 3。可以灵活的删除元素 二.局限性 跟一般的数组比起来,速度上差些 三.添加元素 1.publicvirtualintAdd(objectvalue); 将对象添加到ArrayList的结尾处 ArrayListaList=newArrayList(); aList.Add("a"); aList.Add("b"); aList.Add("c"); aList.Add("d"); aList.Add("e"); 内容为abcde 2.publicvirtualvoidInse