/*------------------------------------------------------------------------
double value;
value = 123;
Console.WriteLine(value.ToString("00000"));
Console.WriteLine(String.Format("{0:00000}", value));
// Displays 00123
value = 1.2;
Console.WriteLine(value.ToString("0.00", CultureInfo.InvariantCulture));
Console.WriteLine(String.Format(CultureInfo.InvariantCulture,
"{0:0.00}", value));
// Displays 1.20
Console.WriteLine(value.ToString("00.00", CultureInfo.InvariantCulture));
Console.WriteLine(String.Format(CultureInfo.InvariantCulture,
"{0:00.00}", value));
// Displays 01.20
CultureInfo daDK = CultureInfo.CreateSpecificCulture("da-DK");
Console.WriteLine(value.ToString("00.00", daDK));
Console.WriteLine(String.Format(daDK, "{0:00.00}", value));
// Displays 01,20
value = .56;
Console.WriteLine(value.ToString("0.0", CultureInfo.InvariantCulture));
Console.WriteLine(String.Format(CultureInfo.InvariantCulture,
"{0:0.0}", value));
// Displays 0.6
value = 1234567890;
Console.WriteLine(value.ToString("0,0", CultureInfo.InvariantCulture));
Console.WriteLine(String.Format(CultureInfo.InvariantCulture,
"{0:0,0}", value));
// Displays 1,234,567,890
CultureInfo elGR = CultureInfo.CreateSpecificCulture("el-GR");
Console.WriteLine(value.ToString("0,0", elGR));
Console.WriteLine(String.Format(elGR, "{0:0,0}", value));
// Displays 1.234.567.890
value = 1234567890.123456;
Console.WriteLine(value.ToString("0,0.0", CultureInfo.InvariantCulture));
Console.WriteLine(String.Format(CultureInfo.InvariantCulture,
"{0:0,0.0}", value));
// Displays 1,234,567,890.1
value = 1234.567890;
Console.WriteLine(value.ToString("0,0.00", CultureInfo.InvariantCulture));
Console.WriteLine(String.Format(CultureInfo.InvariantCulture,
"{0:0,0.00}", value));
// Displays 1,234.57
------------------------------------------------------------------------*/
usnig System;
usnig System.IO;
usnig System.Timers;
usnig Kingdom;
namespace Kingdom
{
class Program
{
static void Main(string[] args)
{
Episode pro=new Episode();
pro.running();
}
}
class Episode
{
DateTime now;
ConsoleKey key;
ConsoleKeyInfo keyinfo;
Timer timer;
int xpos,ypos;
public void elapsed_time_func(object sender, ElapsedEventArgs e)
{
ypos++;
Logging("Time");
}
public void running()
{
timer=new Timer();
timer.Interval=1000;
timer.Elapsed += new ElapsedEventHandler(elapsed_time_func);
timer.Start();
Logging("Start");
while(true)
{
key=Console.ReadKey(true).Key;
//keyinfo=Console.ReadKey(true);
if(key==ConsoleKey.RightArrow) xpos++;
else if(key==ConsoleKey.LeftArrow) xpos--;
else if(key==ConsoleKey.DownArrow) ypos--;
else if(key==ConsoleKey.Escape) break;
/*if(keyinfo.KeyChar=='+')
{
timer.Stop();
timer.Interval += 10;
timer.Start();
}
else if(keyinfo.Key==ConsoleKey.RightArrow) xpos++*/
Logging("Key");
}
timer.Stop();
Logging("Stop");
}
public void Logging(string msg)
{
now=DateTime.Now;
Console.WriteLine("Debug>>" + "Pos[" + ypos.ToString("0000") + "," + xpos.ToString("0000") + "] Time:" + now.ToString("yyyy-MM-dd hh:mm:ss") + " Event:" + msg);
}
}
}
'c# 언어' 카테고리의 다른 글
메시지 처리 함수 (WndProc) (0) | 2021.06.08 |
---|---|
#region을 사용하면 #endregion으로 지시문을 종료해야 합니다. (0) | 2021.06.04 |
namespace(c#) & package(java) (0) | 2021.05.07 |
KeyBoard를 이용한 xpos,ypos 증감 프로그램 (0) | 2021.04.21 |
Tettris by c# console program(4*4 배열의 모양) (0) | 2021.04.15 |