设计一个简单的window应用程序,在文本框中随意输入一个日期,单击“确定“时显示“这一天是星期几”
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27using 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 _1 { public partial class Form1 : Form { public Form1() { InitializeComponent();//控件初始化 } enum Weekday { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday };//声明枚举类型 private void button1_Click(object sender, EventArgs e) { DateTime dt = Convert.ToDateTime(txtDate.Text); Weekday wd = (Weekday)dt.DayOfWeek;//定义枚举变量,将数值转化为枚举值,初始化wd lblShow.Text = txtDate.Text + " is " + wd + "."; } } }
测试结果:
最后
以上就是机智海燕最近收集整理的关于C#设计一个简单的window应用程序,在文本框中随意输入一个日期,单击“确定“时显示“这一天是星期几”的全部内容,更多相关C#设计一个简单内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复