Computer Language/유니티
out참조 (변수가 좀더 필요로 할때.)
알 수 없는 사용자
2014. 4. 14. 15:12
using UnityEngine;
using System.Collections;
public class ExParam : MonoBehaviour {
// Use this for initialization
void Start () {
int a1 = 10;
int b1 = 20;
int avg1 = 40;
int total = 0;
total = GetTotal(a1, b1, out avg1);
print ("total = " + total + ", avg = " + avg1);
}
int GetTotal(int a, int b, out int avg){ //out int 이렇게 선언을 꼭 해줌.
avg = (a + b) / 2;
return a + b;
}
// Update is called once per frame
void Update () {
}
}