๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐ŸŽฎunity/C#4

[C#] Nullable Type ๐ŸŸฆ Nullable Type null ๊ฐ’์„ ๊ฐ€์งˆ ์ˆ˜ ์—†๋Š” ๋ฐ์ดํ„ฐ ํƒ€์ž…์„ null ๊ฐ’์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ํƒ€์ž…์ด๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด bool ํƒ€์ž…์€ ์˜ค์ง true, false ๊ฐ’๋งŒ์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค. (์ดˆ๊ธฐํ™”๋ฅผ ํ•˜์ง€์•Š์œผ๋ฉด false) nullable type์„ ์‚ฌ์šฉํ•˜๋ฉด null ๊ฐ’์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค. ๐ŸŸง Document Nullable Type ๋ฌธ์„œ ๐ŸŸง ์„ ์–ธ int a = 0;// ๊ธฐ๋ณธ ํƒ€์ž… int? b = null;// nullable type int? c = a;// nullable type์— ๊ฐ’์„ ๋„ฃ์„ ์ˆ˜๋„ ์žˆ์Œ - ๋ฐ์ดํ„ฐ ํƒ€์ž… ๋’ค์— ? ๋ฌธ์ž๋ฅผ ๋ถ™์—ฌ์ค€๋‹ค. ๐ŸŸง ๊ธฐ๋ณธ๊ฐ’ ๊ฒ€์‚ฌ int? a = 1; if(a.HasValue) { // ๊ฐ’์ด ์žˆ์Œ. ์ฆ‰ null ๊ฐ’์ด ์•„๋‹˜. } else { // null์„ ๋‹ด๊ณ ์žˆ์Œ... 2022. 11. 14.
[C#] ref & out ๐ŸŸฆ ref & out ref์™€ out ๋ชจ๋‘ ๋ฉ”์„œ๋“œ์— ์ธ์ž๋ฅผ ์ „๋‹ฌํ•  ๋•Œ ์‚ฌ์šฉ๋œ๋‹ค. ํ•˜์ง€๋งŒ ์ฐจ์ด์ ์ด ์žˆ์œผ๋‹ˆ ์ด๋ฅผ ๊ณ ๋ คํ•ด์„œ ์‚ฌ์šฉํ•ด์•ผํ•œ๋‹ค. ๐ŸŸง Document ref ๋ฌธ์„œ out ๋ฌธ์„œ ๐ŸŸง ref ํ‚ค์›Œ๋“œ int a = 1; // ์ดˆ๊ธฐํ™” ํ•„์ˆ˜ // a๋ผ๋Š” ์ธ์ž๋ฅผ ๋„˜๊ฒจ๋ฐ›์Œ public void ChangeValue(ref int a) { } - ํ•ด๋‹น ๋ณ€์ˆ˜๊ฐ€ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋„˜๊ฒจ์ง€๊ธฐ ์ „์— ์ดˆ๊ธฐํ™”๋ฅผ ํ•ด์•ผํ•œ๋‹ค. - ๋ฉ”์„œ๋“œ ์™ธ๋ถ€์—์„œ ๋ฉ”์„œ๋“œ ๋‚ด๋ถ€๋กœ ๊ฐ’์„ ์ „๋‹ฌํ•œ๋‹ค. ๐ŸŸง out ํ‚ค์›Œ๋“œ int a;// ์ดˆ๊ธฐํ™”ํ•  ํ•„์š” ์—†์Œ. // ๋ฉ”์„œ๋“œ ๋‚ด๋ถ€์—์„œ ์ฒ˜๋ฆฌํ•œ ๊ฐ’์„ a์—๊ฒŒ ๋„˜๊ฒจ์คŒ public void ChangeValue(out int a) { } - ํ•ด๋‹น ๋ณ€์ˆ˜๋ฅผ ์ดˆ๊ธฐํ™”ํ•  ํ•„์š”๊ฐ€ ์—†๋‹ค. - a๋ผ๋Š” ๋ณ€์ˆ˜๋ฅผ ๋ฉ”์„œ๋“œ ๋‚ด๋ถ€๋กœ ๋„˜๊ฒจ์ฃผ๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ, ๋ฉ”.. 2022. 10. 26.
Interface, Abstract, Virtual ๐ŸŸฆ Interface, Abstract, Virtual - ํŒจํ„ด ์ฑ…์„ ๊ณต๋ถ€ํ•˜๋Š”๋ฐ ์œ„์˜ ๊ฐœ๋…์ด ์žกํžˆ์ง€์•Š์•„ ์ดํ•ด๊ฐ€ ์–ด๋ ค์› ์Œ - ๋‚˜๋ฆ„๋Œ€๋กœ ์ดํ•ดํ•œ ๊ฒƒ์„ ์ •๋ฆฌํ•จ ๐ŸŸฆ Interface ๐ŸŸง Document https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/interface interface - C# Reference :::no-loc text=interface::: (C# Reference) docs.microsoft.com - ์ธํ„ฐํŽ˜์ด์Šค - ๊ตฌํ˜„ํ•ด์•ผํ•  ๋ฉค๋ฒ„๋“ค์„ ์„ ์–ธํ•˜๋Š” ๊ฒƒ - ์ธํ„ฐํŽ˜์ด์Šค ์•ˆ์—์„œ ๊ตฌํ˜„ ๋ถˆ๊ฐ€ - ์ธํ„ฐํŽ˜์ด์Šค ์•ˆ์— ์“ธ ์ˆ˜ ์žˆ๋Š” ๋ฉค๋ฒ„๋Š” ์ด 4๊ฐœ - Methods - Properties - Indexers // ์ธ๋ฑ์„œ๋ฅผ ๊ณต๋ถ€ํ•œ.. 2021. 11. 12.
C# ์ฃผ์„์— ๋Œ€ํ•œ XML ํƒœ๊ทธ ๐ŸŸฆ XML ํƒœ๊ทธ - summary ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜๋ฉด ๋ฉ”์„œ๋“œ์™€ ํŒŒ๋ผ๋ฏธํ„ฐ์— ๋Œ€ํ•œ ์„ค๋ช…์ด ๋œจ๊ธฐ ๋•Œ๋ฌธ์— ๋”์šฑ ํŽธ๋ฆฌํ•˜๋‹ค. ๐ŸŸง document https://docs.microsoft.com/ko-kr/dotnet/csharp/language-reference/xmldoc/ XML ๋ฌธ์„œ ์ฃผ์„ - /// ์ฃผ์„์„ ์‚ฌ์šฉํ•˜์—ฌ API ๋ฌธ์„œํ™” XML ๋ฌธ์„œ ์ฃผ์„์— ๋Œ€ํ•ด ์•Œ์•„๋ด…๋‹ˆ๋‹ค. ํŠน์ˆ˜ ์ฃผ์„ ํ•„๋“œ์— XML ์š”์†Œ๋ฅผ ๋„ฃ์–ด ์ฝ”๋“œ์˜ ์„ค๋ช…์„œ๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฃผ์„์—์„œ ๋ฌธ์„œ ๋ ˆ์ด์•„์›ƒ์„ ๋นŒ๋“œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. docs.microsoft.com ๐ŸŸง Class - ์Šฌ๋ž˜์‹œ( / ) ์„ธ๋ฒˆ ์ž…๋ ฅ ํ›„ ํƒœ๊ทธ ์ž…๋ ฅ - ์ฃผ์„์œผ๋กœ ์ž…๋ ฅํ•  ๋ถ€๋ถ„ ๋ชจ๋‘ ์Šฌ๋ž˜์‹œ 3๋ฒˆ์„ ์•ž์— ์ž…๋ ฅํ•ด์ค˜์•ผํ•œ๋‹ค. - summary ํƒœ๊ทธ ์•ˆ์— ํด๋ž˜์Šค์— ๋Œ€ํ•œ ์„ค๋ช…์„ ์ž‘.. 2021. 11. 1.
๋ฐ˜์‘ํ˜•