c# 몇 주 및 몇 주 동안의 시작 및 종료 예제 코드 제공

2843 단어
코드 예:
 
  



   
   
   
   <br><br>  


   

       


       

                NumWeeks(new DateTime(2009, 11, 15));

         %>

         <br><br>             /// <summary><br>             /// <br>             /// </summary><br>             /// <param name="a"></param><br>             /// <returns></returns><br>             public  void NumWeeks(DateTime dt)<br>             {<br>                 // <br>                 int year = dt.Year;<br>                 // <br>                 int month = dt.Month;<br>                 // <br>                 DateTime weekStart = new DateTime(year, month, 1);<br>                 // <br>                 DateTime monEnd = weekStart.AddMonths(1).AddDays(-1);<br>                 int i = 1;<br>                 // <br>                 int dayOfWeek = Convert.ToInt32(weekStart.DayOfWeek.ToString("d"));<br>                 // <br>                 DateTime weekEnd = dayOfWeek == 0 ? weekStart : weekStart.AddDays(7 - dayOfWeek); <br><br>                 richTextBox2.Text += " " + i + " : " + weekStart.ToShortDateString() + "   : " + weekEnd.ToShortDateString() + "
";<br><br>                 // <br>                 while (weekEnd.AddDays(1) <= monEnd)<br>                 {<br>                     i++;<br>                     // <br>                     weekStart = weekEnd.AddDays(1);<br>                     // <br>                     weekEnd = weekEnd.AddDays(7) > monEnd ? monEnd : weekEnd.AddDays(7);<br><br>                     richTextBox2.Text += " " + i + " : " + weekStart.ToShortDateString() + "   : " + weekEnd.ToShortDateString() + "
";<br>                 }<br><br>                 richTextBox2.Text += year + " " + month + " " + i + "
";<br>             }</p> <p>        

        

                            Width="845px" >

       


   



좋은 웹페이지 즐겨찾기