c#action和function

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;
}
}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值