當前位置:編程學習大全網 - 編程語言 - 設計壹個簡單的windows應用程序,在文本框中隨意輸入壹個日期,單擊“確定”按鈕時顯示這壹天是星期幾

設計壹個簡單的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];

}

}

}

  • 上一篇:PLC常見故障有哪些
  • 下一篇:智慧樹知到《CNC加工編程》2023見面課答案
  • copyright 2024編程學習大全網