資源簡介
c#日期推算,輸入一個日期,然后輸出這個日期的后天,很簡單的一個代碼,用Visual Studio2010寫的。

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
namespace?年月日測試
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????int?year=Convert.ToInt32(textBox1.Text);
????????????int?month=Convert.ToInt32(textBox2.Text);
????????????int?day=Convert.ToInt32(textBox3.Text);
????????????int?n_year=0n_month=0n_day=0;
????????????int[]?m1=new?int[]{46911};//月份小月30天
????????????int[]?m2=new?int[]{1357810};//大月31天
????????????int[]?m3?=?new?int[]?{?1?3?5?7?8?10?12?};//加12月
?????????
????????????if?(year?>=?1000?&&?year?<=?9999?&&?month?>=?1?&&?month?<=?12?&&?day?>=?1?&&?day?<=?31)
????????????{?
????????????????bool?run;
?
????????????????if(((year?%?400)?==?0)?||?(((year?%?4)?==?0)?&&?((year%?100)?!=?0)))
???????????????????
????????????????{?
???????????????????run=true;
????????????????}
????????????????else??
????????????????{
???????????????????run=false;
????????????????}?//判斷閏年
????????????????/*1*/
????????????????if?((day?>=?1?&&?day?<=?26)||
????????????????????(month!=2&&day==27)||?
????????????????????(month?!=?2?&&?day?==?28)?||
????????????????????((month?==?1?||?month?==?3?||?month?==?5?||?month?==?7?||month?==?8||?month?==?10||month==12)?&&?day?==?29)||
????????????????????((run?==?true)?&&?month?==?2?&&?day?==?27))
????????????????{
????????????????????n_year?=?year;
????????????????????n_month?=?month;
????????????????????n_day?=?day?+?2;
????????????????????lblShow.Text?=?n_year?+?“-“?+?n_month?+?“-“?+?n_day;
????????????????}
????????????????/*2*/???
????????????????else?if?(((month?==4||?month?==6?||?month?==??9||?month?==?11)?&&day==29)||
????????????????????((month?==?1?||?month?==?3?||?month?==?5?||?month?==?7?||month?==?8||?month?==?10)?&&?day?==?30)?||
????????????????????(((run?==?false)?&&?month?==?2?&&?day?==?27)?||((run?==?true)?&&?month?==?2?&&?day?==?28)))
????????????????{
????????????????????n_year?=?year;
????????????????????n_month?=?month?+?1;
????????????????????n_day?=1;
????????????????????lblShow.Text?=?n_year?+?“-“?+?n_month?+?“-“?+?n_day;
????????????????}
????????????????/*3*/
????????????????else?if?(((month?==?4?||?month?==?6?||?month?==?9||month?==?11)&&day==30)||
????????????????????((month?==?1?||?month?==?3?||?month?==?5?||?month?==?7?||?month?==?8||?month?==?10)&&day==31)||
????????????????????(((run?==?false)?&&?month?==?2?&&?day?==?28)?||?((run?==?true)?&&?month?==?2?&&?day?==?29)))
????????????????{
????????????????????n_year=year;
????????????????????n_month=month+1;
????????????????????n_day=2;
????????????????????lblShow.Text?=?n_year?+?“-“?+?n_
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-12-14?21:24??年月日測試\
?????目錄???????????0??2017-12-14?21:24??年月日測試\年月日測試\
?????文件????????9025??2017-11-07?19:45??年月日測試\年月日測試\Form1.Designer.cs
?????文件????????4282??2017-11-07?22:19??年月日測試\年月日測試\Form1.cs
?????文件????????5817??2017-11-07?19:45??年月日測試\年月日測試\Form1.resx
?????文件?????????496??2017-11-07?19:18??年月日測試\年月日測試\Program.cs
?????目錄???????????0??2017-12-14?21:24??年月日測試\年月日測試\Properties\
?????文件????????1362??2017-11-07?19:18??年月日測試\年月日測試\Properties\AssemblyInfo.cs
?????文件????????2882??2017-11-07?19:18??年月日測試\年月日測試\Properties\Resources.Designer.cs
?????文件????????5612??2017-11-07?19:18??年月日測試\年月日測試\Properties\Resources.resx
?????文件????????1102??2017-11-07?19:18??年月日測試\年月日測試\Properties\Settings.Designer.cs
?????文件?????????249??2017-11-07?19:18??年月日測試\年月日測試\Properties\Settings.settings
?????目錄???????????0??2017-12-14?21:24??年月日測試\年月日測試\bin\
?????目錄???????????0??2017-12-14?21:24??年月日測試\年月日測試\bin\Debug\
?????文件???????12288??2017-11-07?23:02??年月日測試\年月日測試\bin\Debug\年月日測試.exe
?????文件???????26112??2017-11-07?23:02??年月日測試\年月日測試\bin\Debug\年月日測試.pdb
?????文件???????11600??2017-11-08?19:51??年月日測試\年月日測試\bin\Debug\年月日測試.vshost.exe
?????文件?????????490??2016-07-16?19:44??年月日測試\年月日測試\bin\Debug\年月日測試.vshost.exe.manifest
?????文件???????20992??2017-11-08?19:51??年月日測試\年月日測試.suo
?????目錄???????????0??2017-12-14?21:24??年月日測試\年月日測試\obj\
?????目錄???????????0??2017-12-14?21:24??年月日測試\年月日測試\obj\x86\
?????目錄???????????0??2017-12-14?21:24??年月日測試\年月日測試\obj\x86\Debug\
?????文件????????2867??2017-11-08?19:51??年月日測試\年月日測試\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件????????6444??2017-11-08?19:51??年月日測試\年月日測試\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件?????????887??2017-11-07?23:02??年月日測試\年月日測試.sln
?????文件?????????180??2017-11-07?19:45??年月日測試\年月日測試\obj\x86\Debug\年月日測試.Form1.resources
?????文件?????????180??2017-11-07?19:34??年月日測試\年月日測試\obj\x86\Debug\年月日測試.Properties.Resources.resources
?????文件?????????990??2017-11-08?19:51??年月日測試\年月日測試\obj\x86\Debug\年月日測試.csproj.FileListAbsolute.txt
?????文件?????????975??2017-11-07?19:45??年月日測試\年月日測試\obj\x86\Debug\年月日測試.csproj.GenerateResource.Cache
?????文件???????12288??2017-11-07?23:02??年月日測試\年月日測試\obj\x86\Debug\年月日測試.exe
?????文件???????26112??2017-11-07?23:02??年月日測試\年月日測試\obj\x86\Debug\年月日測試.pdb
............此處省略5個文件信息
- 上一篇:運用各種邊緣檢測算子進行圖像邊緣檢測
- 下一篇:C#開發大全提高卷ISO鏡像
評論
共有 條評論