오늘 배운 내용
- 조건문
조건문
If 문
if(내용이 참인경우)
{
중괄호 내용을 실행
}
If 와 else if
int a = 1
if(a < 0)
{
Console.WriteLine("Hi");
}
else if (a > 0)
{
Console.WriteLine("Bye");
}
- if문에서
a < 0은 거짓(false)이기때문에 else if문으로 넘어갑니다. else if문에서 a > 0이 참(true)이 나왔기 때문에 결과적으로 출력되는것은 "bye"입니다.
else
int a = 10
if (a < 5)
{
}
else if (a = 7)
{
}
else
{
}
Switch 문
string input = Console.ReadLine();
int inputValue = int.Parse(input)
switch (inputValue)
{
case 1:
Console.WriteLine("마을로 이동");
break;
case 2:
Console.WriteLine("상점으로 이동");
break;
case 3:
Console.WriteLine("던전으로 이동");
break;
default:
Console.WriteLine("아무것도 하지 않음");
break;
}