Computer Language/유니티

선택적 매개변수 (기본값이 있을때 매개변수를 생략)

알 수 없는 사용자 2014. 4. 22. 14:38





using System.Collections;


public class Ex6_9 : MonoBehaviour {

void MyMethod_0(int a = 0){

print(a);

}

void MyMethod_1(int a = 0, int b = 0){

        print (a + " " + b);

}

void MyMethod_2(int a, int b, int c = 10, int d = 20){

print (a + ", " + b + ", " + c + ", " + d);

}

void PrintProfile(string name = "KIM", string phone = "010"){

print (name + "," + phone);

}

// Use this for initialization

void Start () {

MyMethod_0();

MyMethod_1(20);

MyMethod_2(20, 30);

PrintProfile();

PrintProfile("Park");

PrintProfile(phone:"020-494-4844");

PrintProfile("Park", "010-33939-3333");

}

// Update is called once per frame

void Update () {

}

}