프로그래밍 언어/C#

[C#] C# 연습

proApril 2022. 6. 21. 09:45

# 디버깅 (대소문자 주의)

Debug.Log("Hello Unity");

 

# 변수 세팅 

int  a;

float b;

string c;

bool d;

 

# 그룹형 변수 (배열, 리스트)

string[] monsters = {"","",""};

List<string> items = new List<string>();

items.Add("");

items.RemoveAt(0);

 

# 비교연산자

isFullLevel = level ==fullLevel;

bool isEndTutorial = level > 10;

bool isBadCondition = health <= 50 && mana <= 20;  # And 연산자

bool isBadCondition = health <= 50 || mana <= 20;  # Or 연산자

string condition = isBadCondition ? "나쁨" : "좋음";

 

# 조건문

if (true) {

}

else {

}

 

switch (파라미터) {

      case "":

             break;

      default:

             break;

}

 

# 반복문

while () {

}

for (int count = 0; count < 10 ; count++)  {

}

foreach (string monster in mosters){

}

 

# 함수

int Heal(int health) # 반환할 타입을 명시해줘야함.

{

        return health;

}

 

void Heal() # 함수가 반환할 데이터가 없다는 뜻

{

}