๐ŸŽฎ Unity Study/C#

[C#] ? Question Mark

ibelieveinme 2023. 8. 18. 20:39
728x90

C# 6.0 ๋ถ€ํ„ฐ Null ์ฒดํฌ ์—ฐ์‚ฐ์ž ? ์™€ ?? ๊ฐ€ ์ถ”๊ฐ€ ๋˜์—ˆ๋”ฐ.

๊ทธ๋ž˜์„œ ์•„๋ž˜ ์ฝ”๋“œ๋Š” ๊ฐ™์€ ์˜๋ฏธ์ด๋‹ค.

if(current == null){
	current = gameObject;
}
current.Start();
current?.Start();

 

๋˜ํ•œ C# 8.0 ๋ถ€ํ„ฐ ๋„ ํ• ๋‹น์ž ??= ๋„ ์ถ”๊ฐ€๋˜์—ˆ๋‹ค.

 

 

728x90