LoginSignup
1
0

More than 5 years have passed since last update.

現在の時刻を表示するプログラム

Posted at

開発環境

OS : Microsoft Windows10 (64bit)
IDE : Microsoft Visual Studio 2012

現在の時刻を取得プログラム

まず↓の画像の用に今回はVisualC#のコンソールアプリを選択します。
今日の日付1.png
次にプロジェクトの名前を決めます。
今回はtestと言う名前を使ってます。
選択した物が間違ってなければ右下にOKをクリックしてもらうと↓の画像の用になります。
今日の日付2.png

ソースコード

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{

    class Program
    {
        static void Main()
        {
           //現在の時刻を取得

            DateTime dt = DateTime.Now;
            Console.WriteLine(dt);

            Console.ReadKey();
        }
    }
}

ソースコードを入力して実行した画面

今日の日付3.png
実行結果
今日の日付4.png

今回使った時刻を取得するソースの部分

DateTime dt = DateTime.Now;
            Console.WriteLine(dt);
1
0
0

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
1
0