2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

C# DateTime.Part1

Last updated at Posted at 2021-09-11

Datetimeの扱い方

C#でのDateTime型を定義して宣言するときは

var employee = new Employee
{
HireDeta = new DateTime
}

必ずnewをつけるようにしてください。

Datetimeを呼び出す時

var enloy
{
   NUmber = 352,
   FirstName = "涼太",
   LastName = "田中",
   HireDate = new DateTime(2015, 10, 1)
};
Console.WriteLine("作業員番号{0}の{1}は、{2}年に入社しました。",
   employee.Number, employee.FullName, employee.Year);
  • DateTimeの後ろにYearをつけると2015が代入される。Dayだと1、Monthだと10となる。
2
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?