自己做了一个简易月日选择器,其中4、6、9、11月是30天,我进行分别赋值。
s == "4" || s == "6" || s == "9" || s == "11"
如果有更多的赋值,有没有简写的方式?
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 comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
comboBox2.Items.Clear();
string s = comboBox1.Text;
if (s == "2")
{
for (int i = 1; i <= 28; i++)
{
comboBox2.Items.Add(i); }
}
else if (s == "4" || s == "6" || s == "9" || s == "11")
{
for (int i = 1; i <= 30; i++)
{
comboBox2.Items.Add(i);
}
} else
{
for (int i = 1; i <= 31; i++)
{
comboBox2.Items.Add(i);
}
}
}
}
}
多赋值、简写、C#
s == "4" || s == "6" || s == "9" || s == "11"
如果有更多的赋值,有没有简写的方式?
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 comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
comboBox2.Items.Clear();
string s = comboBox1.Text;
if (s == "2")
{
for (int i = 1; i <= 28; i++)
{
comboBox2.Items.Add(i); }
}
else if (s == "4" || s == "6" || s == "9" || s == "11")
{
for (int i = 1; i <= 30; i++)
{
comboBox2.Items.Add(i);
}
} else
{
for (int i = 1; i <= 31; i++)
{
comboBox2.Items.Add(i);
}
}
}
}
}
多赋值、简写、C#
if(arr.Contains(s)){...};
DateTime.DaysInMonth;http://msdn.microsoft.com/zh-cn/library/system.datetime.isleapyear(v=VS.80).aspxhttp://msdn.microsoft.com/zh-cn/library/system.datetime.daysinmonth(v=VS.80).aspx
int month= 2;
int days = DateTime.DaysInMonth(2013, month);
//输出某年某月多少天
Console.WriteLine(days);
参考:http://bbs.csdn.net/topics/390361320
下载:http://download.csdn.net/detail/joyhen/5041462
公历→农历
2013年06月08日
双子座
二〇一三年五月初一
癸巳〖蛇〗 戊午月 乙巳日 甲申时
今属:木;五行:水火土木金;缺:。
纳音五行:长流水。
公历→农历
2013年06月08日
双子座
二〇一三年五月初一
癸巳〖蛇〗 戊午月 乙巳日 甲申时
今属:木;五行:水火土木金;缺:。
纳音五行:长流水。