C# 변수 본문 (리턴,연산자)
-1.return;
리턴값이란 외부의 연산값이나 객체상태값등을 끝나고나면 외부에 반환하는것을 말한다 .
void[리턴값]] Damage1이름 or 식별자[인자값]] //멤버 함수
public void Damage1(int _Dmg)
{
HP= HP - _Dmg;
}
리턴값은 자신이 리턴해주려는 자료형(int)과 동일한 자료형(int _Dmg) 이여야한다
public int DamageTOHPReturn(int _Dmg)
{
HP = HP - Dmg;
return HP;
}
Console.WriteLine(New Player.DamageToHPReturn(50));
-2. bool 참 , 거짓
! 반대값을 리턴해준다
Result = !true; // true 면 false
Result = !true; // flase 면 true
-3. 논리 연산자
&& 둘다 true 일때만 true
Result = true && false ; // AND 둘중하나 >false
Result = true && true ; // AND 두개 트루 > true
Result = true && true && false ; // > flase
*|| 하나라도 true 있으면 트루
Result = true || false ; // or >true
Result = false || false ; // or >false
^ 이녀석은 같으면 거짓
다르면 참이다
양쪽이 다르면 true
양쪽이 같으면 false 로 연산
Result = true ^ false ; // XOR > true
Result = false ^ true ; // XOR > true
Result = false ^ false ; // XOR > false
Result = true ^ true ; // XOR > flase
Leave a comment