CSharp examples for System:DateTime Month
Get Month Number
using System.Text; using System.Linq; using System.Collections.Generic; using System;//from www . j a v a 2s . c o m public class Main{ public static int GetMonthNumber(DateTime d) { int[] t = { 1, 3, 5, 7, 8, 10, 12 }; int[] t1 = { 4, 6, 9, 11 }; int dt = 0; if (t.Contains<int>(d.Month)) dt = 31; if (t1.Contains<int>(d.Month)) dt = 30; if (d.Month == 2) { if (d.Year % 4 == 0) { dt = 29; } else { dt = 28; } } return dt; } }