SPlayer player;
void Move(Splayer player)
{
ย ย ย ย // function implementation
}
์ธ์คํด์ค ์ด๋ฆ๊ณผ ๋งค๊ฐ๋ณ์ ์ด๋ฆ์ด ๊ฐ์์ ๋ณ์ ๊ฐ๋ฆฌ๊ธฐ ๋ผ์๋๋ฐ ์์ฌ์ฐ๋ฉด์๋ ์ ํท๊ฐ๋ฆฌ๊ฒ ์ด๋ฆ ์ง๋ ๋ฐฉ๋ฒ ์๋
void Move(Splayer player)
{
ย ย ย ย // function implementation
}
์ธ์คํด์ค ์ด๋ฆ๊ณผ ๋งค๊ฐ๋ณ์ ์ด๋ฆ์ด ๊ฐ์์ ๋ณ์ ๊ฐ๋ฆฌ๊ธฐ ๋ผ์๋๋ฐ ์์ฌ์ฐ๋ฉด์๋ ์ ํท๊ฐ๋ฆฌ๊ฒ ์ด๋ฆ ์ง๋ ๋ฐฉ๋ฒ ์๋
this
์๊ฒน์น๋๊ฒ ์ข๊ธด ํ๋ฐ, this ์ฐ๋ ์ต๊ด์ด ์ ค ๋์๋ฏ
1. ๋ฉค๋ฒ๋ณ์ ์์ ์ธ๋๋ฐ ๋ถ์ด๊ธฐ 2. ํจ์ ํ๋ผ๋ฏธํฐ ๋ค์ ์ธ๋๋ฐ ๋ถ์ด๊ธฐ 3. ๊ฑ this. ์ฐ๊ธฐ
๋ฉค๋ฒ๋ ๋๋ฌธ์๋ก ์์, ์ธ์๋ ์๋ฌธ์๋ก ์์
๋ด๋ถ ๋ฉค๋ฒ์ผ๊ฒฝ์ฐ _ ๋ฅผ ๋ถ์ด๊ธฐ๋ํจ
private int _Value; public int Value { get => this._Value; set { this._Value = Math.Max(0, value); } }
setter ์ญํ ํ๋ ๋ฉ์๋ ์ธ์๋ ์ ๋์ new ๋ฅผ ๋ถ์ด๊ธฐ๋ ํ๋ค public void SetValue(int newValue) => this.Value = Math.Max(0, newValue);
https://source.dot.net/#System.Private.CoreLib/List.cs,cf7f4095e4de7646
์ด๋ฐ๊ฑฐ ๋ด๋ด ๋ด๊ฐ ๋ค๋๋ ํ์ฌ์์๋ ์ธ๋๋ฐ + ์นด๋ฉ ๊ตญ๋ฃฐ์ด์ผ