处理一年中的月份天数的输出
知识点 :
数组+交错
Module Module1 Sub Main() Dim calendars()() As Double = New Double(11)() {} Dim month As Integer Dim days As Integer Dim dayValue,i As Integer For month = 0 To 11 days = DateTime.DaysInMonth(Year(Now),month + 1) calendars(month) = New Double(days - 1) {} i = 0 For Each dayValue In calendars(month) calendars(month)(i) = i + 1 i += 1 Next Next month For month = 0 To 11 i = 0 Console.WriteLine("{0}月",month + 1) For Each dayValue In calendars(month) Console.Write(" {0}",calendars(month)(i)) i += 1 Next Console.WriteLine() Next month Console.ReadLine() End Sub End Module
运行效果: