.NET 中的常用

1. 获取当前为第几周(注意:每周日算一周的第一天,)

代码
/*
 * Author: Sandals
 * Blog  : 
http://www.cnblogs.com/sandals
 * Date  : 2010-08-07 22:27
 * Description: 获取当前周
 * 
*/

using System;
using System.Globalization;

namespace Sandals.Test
{
    
class Program
    {
        
static void Main(string[] args)
        {
            
// Gets the Calendar instance associated with a CultureInfo.
            CultureInfo myCul = new CultureInfo("zh-CN");
            Calendar myCal 
= myCul.Calendar;

            
// Gets the DTFI properties required by WeekOfYear.
            CalendarWeekRule myCWR = myCul.DateTimeFormat.CalendarWeekRule;
            DayOfWeek myDOW 
= myCul.DateTimeFormat.FirstDayOfWeek;

            
// Displays the total number of weeks in current year.
            DateTime lastDateOfCurrentYear = new DateTime(DateTime.Now.Year, 1231);

            Console.WriteLine(
"There are {0} weeks in the current year({1})", myCal.GetWeekOfYear(lastDateOfCurrentYear, myCWR, myDOW), lastDateOfCurrentYear.Year);
            Console.WriteLine(
"Today is {0}, and it is the {1}th week", DateTime.Now, myCal.GetWeekOfYear(DateTime.Now, myCWR, myDOW));
        }
    }
}

 

运行结果:

 

2. 在Console Application中不能使用Server.MapPath, 怎么办?

    System.IO.Path.GetFullPath(".");

 

3. EventLog所在的注册表位置: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog

 .EventLog文件所在位置: C:\windows\System32\winevt\Logs

 

4. 开发自定义服务器控件:http://msdn.microsoft.com/zh-cn/library/zt27tfhy(v=VS.80).aspx

 

5. javascript with asp.net server control: http://weblogs.asp.net/dwahlin/archive/2007/04/29/creating-custom-asp-net-server-controls-with-embedded-javascript.aspx

posted @ 2010-08-07 22:34  sandals  阅读(354)  评论(0)    收藏  举报