回答編集履歴
1
コンソールアプリケーションについて追記
answer
CHANGED
@@ -75,4 +75,35 @@
|
|
75
75
|
}
|
76
76
|
|
77
77
|
```
|
78
|
-
タイマーについては`System.Timers.Timer`の他にFormで使いやすい`System.Windows.Forms.Timer`もあります。
|
78
|
+
タイマーについては`System.Timers.Timer`の他にFormで使いやすい`System.Windows.Forms.Timer`もあります。
|
79
|
+
|
80
|
+
---
|
81
|
+
**追記しました:2019/01/01 04:34 **
|
82
|
+
|
83
|
+
コンソールアプリケーションとしての時計サンプルです。現在時刻を表示しますが、改行はせず、行頭に復帰(CR/carriage return)することで同じ行に現在時刻を表示し続けます。
|
84
|
+
|
85
|
+
```C#
|
86
|
+
// Program.cs
|
87
|
+
//
|
88
|
+
// C> csc Program.cs
|
89
|
+
//
|
90
|
+
using System;
|
91
|
+
|
92
|
+
namespace ConApp1
|
93
|
+
{
|
94
|
+
class Program
|
95
|
+
{
|
96
|
+
static void Main(string[] args)
|
97
|
+
{
|
98
|
+
while (true)
|
99
|
+
{
|
100
|
+
string s = DateTime.Now.ToLocalTime().ToLongTimeString();
|
101
|
+
Console.Write("\x0d" + s);
|
102
|
+
System.Threading.Thread.Sleep(1000);
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
```
|
108
|
+
実行例です。終了はCTRL+Cで強制終了してください。
|
109
|
+

|