現在の日時を取得するNowプロパティについてはこちらの記事を参照してください。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace CalcDateTime2020
{
public partial class FormCalcMonth : Form
{
public FormCalcMonth()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
textBox1.Text = dt.ToString("yyyy/MM/dd");
}
}
}
1
を与えます。 DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
textBox1.Text = dt.ToString("yyyy/MM/dd");