Console Color
//Console Color
//글자색 컨트롤
Console.ForegroundColor = ConsoleColor.Green;
//Console.ForegroundColor = (ConsoleColor)10
//글자 배경 컨트롤
Console.BackgroundColor = ConsoleColor.Red;
Console.WriteLine("선택하신 무기가 장착 되었습니다.");
Console.ResetColor(); //기본 색상으로 돌아감(글자색 , 배경색 포함)
/*
//c++ 에서는
//SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
//위의 함수를 사용.
//color는 2바이트 숫자를 가져옴. (WORD = unsigned short)
//16진수로 0x00~0xFF까지. 앞수가 배경, 뒷수가 글자색
*/
'공부 > C#' 카테고리의 다른 글
상속 정의 (0) | 2016.05.06 |
---|---|
class 변수 선언 - get, set (0) | 2016.05.06 |
시간 측정 Stopwatch (0) | 2016.05.04 |
반복문 (0) | 2016.05.04 |
비트 연산 (0) | 2016.05.04 |
시간 측정 Stopwatch
//클래스 추가
using System.Diagnostics;
//아래는 코드 추가 부분
//시간 측정
Stopwatch sw = new Stopwatch(); //생성
sw.Start(); //시작
sw.Stop(); //중지
long time = sw.ElapsedMilliseconds; //밀리언초 반환
sw.Reset(); //시간리셋
sw.Restart(); //재시작
'공부 > C#' 카테고리의 다른 글
class 변수 선언 - get, set (0) | 2016.05.06 |
---|---|
Console Color (0) | 2016.05.04 |
반복문 (0) | 2016.05.04 |
비트 연산 (0) | 2016.05.04 |
switch (0) | 2016.05.04 |
//반복문
int i = 0;
while(i < 10)
{
++i;
Console.WriteLine("While : {0}", i);
}
i = 0;
do
{
++i;
Console.WriteLine("Do While : {0}", i);
} while (i < 10);
int[] test = new int [10];
for (int j = 0; j < test.Length; ++j)
{
test[j] = j;
Console.WriteLine("For : {0}", j);
}
//foreach(int nn in test) //test에 들어있는 것은 nn 변수로 받겠다
//{
// Console.WriteLine("Foreach : {0}", nn);
//}
foreach (var nn in test) //c++ 에서 auto 가 C# 에서 var로 되었다
{
Console.WriteLine("Foreach : {0}", nn);
}
'공부 > C#' 카테고리의 다른 글
Console Color (0) | 2016.05.04 |
---|---|
시간 측정 Stopwatch (0) | 2016.05.04 |
비트 연산 (0) | 2016.05.04 |
switch (0) | 2016.05.04 |
사칙연산 (0) | 2016.05.04 |