using System;
using System.Collections.Generic;
using System.Reflection;
namespace TimeTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(“Hello World!”);
Action x = Console.WriteLine;
Func xm = new Func(Timeif);
x(“8”);
x.Invoke(“8”);
xm.Invoke();
Teast teast = new Teast();
//int[] num = new int[8];
//int[] num = new int[] {0,1,2 };
MethodInfo mInfo = typeof(Program).GetMethod(“Timeif”);
object[] parameters = new object[] { “20”,“30” };
teast.GetType().GetMethod(“Add”).Invoke(teast, parameters);
Timeif();
string b = Timeif1();
}
//8点,12点为切割
public static string Timeif()
{
string times = “”;
string dts = DateTime.Now.ToString(“yyyyMMdd”);
DateTime dt = DateTime.Now;
string monthNow= DateTime.Now.Month.ToString();
DateTime startMonth = dt.AddDays(1 - dt.Day); //本月月初
string s = startMonth.AddMonths(1).AddDays(-1).ToString(“yyyyMMdd”); //本月月末
if (dts == s)
{
int a = Convert.ToInt32(DateTime.Now.Hour);
int m = 12;
if (a > m)
{
times = DateTime.Now.AddDays(1).ToString(“yyyyMMdd”);
}
if (a < m)
{
times = DateTime.Now.AddDays(0).ToString(“yyyyMMdd”);
}
return times;
}
if (dts != s)
{
int v = Convert.ToInt32(DateTime.Now.Hour);
int n = 8;
if (v > n)
{
times = DateTime.Now.AddDays(0).ToString(“yyyyMMdd”);
}
if (v < n)
{
times = DateTime.Now.AddDays(-1).ToString(“yyyyMMdd”);
string month = DateTime.Now.AddDays(-1).Month.ToString();
if (month!=monthNow)
{
times = DateTime.Now.ToString(“yyyyMMdd”);
}
}
return times;
}
return dts;
}
public static string Timeif1()
{
string times = “”;
int v = Convert.ToInt32(DateTime.Now.Hour);
int n = 8;
if (v > n)
{
times = DateTime.Now.AddDays(0).ToString(“yyyyMMdd”);
}
if (v < n)
{
times = DateTime.Now.AddDays(-1).ToString(“yyyyMMdd”);
}
return times;
}
}
}