728x90
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Salary : MonoBehaviour
{
private int salary;
public int SalaryP{get{return salary;} private set{if(value < 0) salary = 10; else salary = value;}}//salary의 프러퍼티를 선언해줍니다.
public int Bonus {get: set:}
// Start is called before the first frame update
void Start()
{
salary = 10; // 10의 값이 salary = value의 value로
// salary = value의 salary가 private int salary의 salary로 들어갑니다.
Bonus = 10;
print(Bonus);//property를 변수취급 할 수 있습니다.
}
}
728x90