Windows 窗体
一组用于开发图形用户界面的 .NET Framework 托管库。
118 个问题
我正在 Windows 窗体应用程序中制作时钟。例如,现在“ddd”显示“Mon”。但我希望它说“月”。目前 Form1 具有:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Aesthetic_Date_Clock
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void tmrTimer_Tick(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToString("HH : mm : ss");
label2.Text = DateTime.Now.ToString("yy / MM / dd");
label3.Text = DateTime.Now.ToString("ddd");
}
}
}
Note:此问题总结整理于:How do I code "day of the week" in Japanese in Visual Studios?
您可以使用 DateTime.DayOfWeek 属性来获取此实例表示的星期几。 请参考以下代码:
var culture = new System.Globalization.CultureInfo("ja-JP");
var day = culture.DateTimeFormat.GetDayName(DateTime.Today.DayOfWeek);
label3.Text = day;
如果答案是正确的,请点击“接受答案”并点赞。 如果您对此答案还有其他疑问,请点击“评论”。
注意:如果您想接收相关电子邮件,请按照我们的文档中的步骤启用电子邮件通知 此线程的通知。