php判断是否是节假日,C#编程之C#判断是否是节假日
本文主要向大家介紹了C#編程之C#判斷是否是節(jié)假日,通過具體的內(nèi)容向大家展示,希望對(duì)大家學(xué)習(xí)C#編程有所幫助。
using?Newtonsoft.Json.Linq;
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
namespace?holiday
{
class?Program
{
static?void?Main(string[]?args)
{
//引用Newtonsoft.Json.dll
//
//http://www.downza.cn/soft/212414.html?下載地址
bool?isHoliday?=?IsHolidayByDate("20180101");
}
//?判斷是不是節(jié)假日,節(jié)假日返回true
///
///
日期格式:yyyyMMdd
///
public?static?bool?IsHolidayByDate(string?date)
{
bool?isHoliday?=?false;
System.Net.WebClient?WebClientObj?=?new?System.Net.WebClient();
System.Collections.Specialized.NameValueCollection?PostVars?=?new?System.Collections.Specialized.NameValueCollection();
PostVars.Add("d",?date);//參數(shù)
try
{
//??用法舉例?????????????????//??檢查具體日期是否為節(jié)假日,工作日對(duì)應(yīng)結(jié)果為?0,?休息日對(duì)應(yīng)結(jié)果為?1,?節(jié)假日對(duì)應(yīng)的結(jié)果為?2;
//???檢查一個(gè)日期是否為節(jié)假日?http://www.easybots.cn/api/holiday.php?d=20130101
//??檢查多個(gè)日期是否為節(jié)假日?http://www.easybots.cn/api/holiday.php?d=20130101,20130103,20130105,20130201
//獲取2012年1月份節(jié)假日?http://www.easybots.cn/api/holiday.php?m=201201
//獲取2013年1?/?2月份節(jié)假日?http://www.easybots.cn/api/holiday.php?m=201301,201302
byte[]?byRemoteInfo?=?WebClientObj.UploadValues(@"http://www.easybots.cn/api/holiday.php",?"POST",?PostVars);//請(qǐng)求地址,傳參方式,參數(shù)集合
string?sRemoteInfo?=?System.Text.Encoding.UTF8.GetString(byRemoteInfo);//獲取返回值
string?result?=?JObject.Parse(sRemoteInfo)[date].ToString();
if?(result?==?"0")
{
isHoliday?=?false;
}
else?if?(result?==?"1"?||?result?==?"2")
{
isHoliday?=?true;
}
}
catch
{
isHoliday?=?false;
}
return?isHoliday;
}
}
}
本文由職坐標(biāo)整理并發(fā)布,希望對(duì)同學(xué)們有所幫助。了解更多詳情請(qǐng)關(guān)注職坐標(biāo)編程語言C#.NET頻道!
總結(jié)
以上是生活随笔為你收集整理的php判断是否是节假日,C#编程之C#判断是否是节假日的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c++编写手机小游戏代码_C++代码实现
- 下一篇: python井字棋