设计一个简单的windows应用程序,在文本框中随意输入一个日期,单击“确定”按钮时显示这一天是星期几
示例:
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 test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
enum WeekDay { 星期天,星期一,星期二,星期三,星期四,星期五,星期六};
private void button1_Click(object sender, EventArgs e)
{
DateTime dt = Convert .ToDateTime ( textBox1 .Text);
label1.Text = "\n这一天是" + dt.DayOfWeek;
WeekDay wd =(WeekDay ) dt.DayOfWeek;
label1.Text+= "(即′:"+wd +")";
}
}
}
扩展资料
设计一个简单的Windows程序,输入5个数字,然后排序并输出;
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 bb
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int[]a=new int[5];
int i = 0;
private void button1_Click(object sender, EventArgs e)
{
if (i < 5)
{
a[i] = Convert.ToInt32(textBox1.Text);
label2.Text += Convert .ToString( a[i])+" ";
i++;
textBox1.Text = "";
}
}
private void Form1_Load(object sender, EventArgs e)
{
label2.Text = "排序前的数字序列:";
}
private void button2_Click(object sender, EventArgs e)
{
Array.Sort(a);
label2.Text += "\n排序后的数字序列:"+a[0]+" "+a[1]+" "+a[2]+" "+a[3]+" "+a[4];
}
}
}
2024-07-20 广告