public static int DaysInMonth (int year, int month)
{
     if ((month < 1) || (month > 12))
     {
          throw new ArgumentOutOfRangeException("month", Environment.GetResourceString("ArgumentOutOfRange_Month"));
     }
     int[] numArray1 = DateTime.IsLeapYear(year) ? DateTime.DaysToMonth366 : DateTime.DaysToMonth365;
     return numArray1[month] - numArray1[month - 1];

解决方案 »

  1.   

    哦。因为这一软件限制一个月使用期。我在找这代码。
    下面的这个是不是呀
    public int DayOfYear
    {
         get
         {
              return GetDatePart(1);
         }

      

  2.   

    Private Function GetDatePart(ByVal part As Integer) As Integer
         ' Method Body Address: 45408
         Dim num2 As Integer = CInt((Me.InternalTicks / 864000000000))
         Dim num3 As Integer = (num2 / 146097)
         num2 = (num2 - (num3 * 146097))
         Dim num4 As Integer = (num2 / 36524)
         If (num4 = 4) Then
              num4 = 3
         End If
         num2 = (num2 - (num4 * 36524))
         Dim num5 As Integer = (num2 / 1461)
         num2 = (num2 - (num5 * 1461))
         Dim num6 As Integer = (num2 / 365)
         If (num6 = 4) Then
              num6 = 3
         End If
         If (part = 0) Then
              Return (((((num3 * 400) + (num4 * 100)) + (num5 * 4)) + num6) + 1)
         End If
         num2 = (num2 - (num6 * 365))
         If (part = 1) Then
              Return (num2 + 1)
         End If
         Dim flag1 As Boolean = ((num6 = 3) AndAlso ((Not num5 = 24) OrElse (num4 = 3)))
         Dim numArray1 As Integer() = IIf(flag1, DateTime.DaysToMonth366, DateTime.DaysToMonth365)
         Dim num7 As Integer = (num2 >> 6)
         Do While (num2 >= numArray1(num7))
              num7 += 1
         Loop
         If (part = 2) Then
              Return num7
         End If
         Return ((num2 - numArray1((num7 - 1))) + 1)
    End Function