본문 바로가기

C

C# 프로그래밍 - if문 조건문 if/else

 

 

 

i

if문 조건문

 

 

 

 

비교 연산자

 

 

 

if else 조건문

 

int a = -3;
if (a == 1){
	print("a는 1");
}else{
	print("a는 1이 아님");
}
//콘솔에 거짓 출력

 

int a = 1;
if (a == 1){
	print("a는 1");
}else{
	print("a는 1이 아님");
}
//콘솔에 참 출력

 

 

 

 

int a = 3;
if(a==1){
    Console.WriteLine("a 1");
}else if(a==2){
    Console.WriteLine("a 2");
}else{
    Console.WriteLine("a는 1, 2 nothing");
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

사용 컴파일러 https://www.onlinegdb.com/online_csharp_compiler

출처 - https://youtu.be/ErR0y2UBNWw?list=PL3aflPKr1txL3MdCEAFrwaKUCsiTUcJCk