C#

Garbage Collector

July 10 2022

GC ๊ธฐ๋ณธ์‚ฌํ•ญ CLR์—์„œ ์ž๋™ ๋ฉ”๋ชจ๋ฆฌ ๊ด€๋ฆฌ ์—ญํ• ์„ ํ•˜๊ธฐ ์œ„ํ•ด GC๋ฅผ ๋‘”๋‹ค ์‚ฌ์šฉ์ž๋Š” ๋ฉ”๋ชจ๋ฆฌ ํ•ด์ œ ๋“ฑ ๊ด€๋ฆฌ ์ž‘์—…์„ ์œ„ํ•œ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค ๋ฉ”๋ชจ๋ฆฌ ๋ˆ„์ˆ˜ ๋ฐ ๋ฉ”๋ชจ๋ฆฌ ๋ฐ˜ํ™˜, ํ•ด์ œ๋œ ๋ฉ”๋ชจ๋ฆฌ์— ์ ‘๊ทผ ๋“ฑ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐ GC์— ์˜ํ•ด ํšจ์œจ์ ์œผ๋กœ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ํ• ๋‹น

Type

July 03 2022

Value Type ๊ฐ’์ด ๋ฐ”๋กœ ํ• ๋‹น๋˜๋Š” ํƒ€์ž… ์ง์ ‘ ๊ฐ’์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค int, float, char ๋“ฑ์ด ์ด์— ํ•ด๋‹นํ•œ๋‹ค System.ValueType์œผ๋กœ๋ถ€ํ„ฐ ์ƒ์†

Method & Virtual Table

July 02 2022

Virtual Table์˜ ๊ตฌ์กฐ C#์—์„œ ๋ชจ๋“  ํด๋ž˜์Šค๋Š” System.Object ํด๋ž˜์Šค์—์„œ ์ƒ์†๋˜๋ฏ€๋กœ VTable์„ ๊ฐ–๋Š”๋‹ค ๊ธฐ๋ณธ์ ์œผ๋กœ ToString, Equals, GetHashCode, Finalize ๋ฉ”์„œ๋“œ๋ฅผ VTable์— ๊ฐ–๋Š”๋‹ค Baseํด๋ž˜์Šค๊ฐ€ ๊ฐ€์ƒ ๋ฉ”์„œ๋“œ๊ฐ€ ์—†๋‹ค๋ฉด ์ด์™ธ์˜ ๋ฉ”์„œ๋“œ๋“ค์€ VTable Slo...

Abstract Data Type

July 02 2022

์ถ”์ƒ์  ์ž๋ฃŒํ˜• ADT ์ž๋ฃŒ ์ž์ฒด์˜ ํ˜•ํƒœ์™€ ์—ฐ์‚ฐ์„ ์ˆ˜ํ•™์ ์œผ๋กœ๋งŒ ์ •์˜ํ•œ ๊ฒƒ

Truth About Value Type

June 22 2022

Value type์ด๋ฉด ๋ชจ๋‘ stack์— ์ €์žฅ๋œ๋‹ค? Value type์€ stack์— ์ €์žฅ๋  ์ˆ˜ ์žˆ๋‹ค ํ•ญ์ƒ stack์— ์ €์žฅ๋˜๋Š” ๊ฒƒ์€ ์•„๋‹ˆ๋‹ค ํ”„๋กœ๊ทธ๋ž˜๋จธ๋Š” ํŠน์ • ๊ฐ์ฒด์— ๋Œ€ํ•ด stack์— ์ €์žฅ๋˜๋Š”์ง€ heap์— ์ €์žฅ๋˜๋Š”์ง€๋ฅผ ์•Œ์•„์•ผํ•  ํ•„์š”๊ฐ€ ์žˆ์—ˆ๋‹ค ์‚ฌ์šฉ์ž์—๊ฒŒ ๋…ธ์ถœ๋˜์ง€ ์•Š์€ ์ƒํƒœ๋กœ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š”...

Struct vs. Class

June 14 2022

Struct ๊ฐ’ ํƒ€์ž… allocation ๋ฐ deallocation ์‹œ ์ฐธ์กฐ ํƒ€์ž…๋ณด๋‹ค ์†Œ์š”๊ฐ€ ์ ๋‹ค stack์— ์ €์žฅ nested struct ๊ตฌ์กฐ์ธ ๊ฒฝ์šฐ inline member๋“ค์€ private by default

string

May 17 2022

string vs String

Boxing & Unboxing

May 17 2022

๊ฐ’ ํ˜•์‹ vs. ์ฐธ์กฐ ํ˜•์‹

Array

May 14 2022

Difference between Array, ArrayList, List Array

Closure

January 15 2022

์˜ˆ์‹œ case 1

Template vs. Generic

November 11 2021

C++ Template vs. C# Generic C++ ์€ ์ปดํŒŒ์ผ์ด 1๋ฒˆ ์ผ์–ด๋‚˜๊ณ , C# ์ œ๋„ค๋ฆญ์€ ์ปดํŒŒ์ผ์ด 2๋ฒˆ ์ผ์–ด๋‚œ๋‹ค. C++ ํ…œํ”Œ๋ฆฟ์€ ์‚ฌ์šฉํ•˜์ง€ ์•Š์œผ๋ฉด ์ปดํŒŒ์ผํ•˜์ง€ ์•Š๋Š”๋‹ค. ํ•˜์ง€๋งŒ, C# ์ œ๋„ค๋ฆญ์€ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋”๋ผ๋„ ๊ทธ์— ๊ด€๋ จ๋œ ์ •๋ณด๋ฅผ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•œ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๊ฐ€ ์ƒ์„ฑ๋œ๋‹ค. ์ œ๋„ค๋ฆญ์€ ๋น„ํ˜•์‹ ํƒฌํ”Œ๋ฆฟ ...

dynamic ํ‚ค์›Œ๋“œ

August 21 2021

๋™์  ํ˜•์‹ dynamic ๋ณ€์ˆ˜ ๋ฐ ํ•ด๋‹น ๋ฉค๋ฒ„์— ๋Œ€ํ•œ ์ฐธ์กฐ ์‚ฌ์šฉ์— ๋Œ€ํ•œ ์ปดํŒŒ์ผ ํƒ€์ž„ ๊ฒ€์‚ฌ๋ฅผ ํŒจ์‹ฑ ๋Ÿฐํƒ€์ž„์—์„œ ํ™•์ธ ๋Œ€๋ถ€๋ถ„์˜ ์ƒํ™ฉ์—์„œ object ์ฒ˜๋Ÿผ ๋™์ž‘ ๊ทธ๋Ÿฌ๋‚˜ ์ปดํŒŒ์ผ๋Ÿฌ๊ฐ€ ํ˜•์‹์„ ๊ฒ€์‚ฌํ•˜์ง€ ์•Š์€ ์ƒํƒœ ์ปดํŒŒ์ผ ํƒ€์ž„์„ ๊ฑฐ์น˜๋ฉฐ object ํƒ€์ž…์œผ๋กœ ๋ณ€ํ™˜ ๋Ÿฐํƒ€์ž„์—์„œ dynamic...

ContainsKey & TryGetValue

June 30 2021

TryGetValue vs. ContainsKey? ```csharp // key๊ฐ€ ์žˆ๋Š”์ง€ ์ฒดํฌ public bool ContainsKey(TKey key) { return (this.FindEntry(key) >= 0); }

default ํ‚ค์›Œ๋“œ

June 14 2021

default ์—ฐ์‚ฐ์ž default ํ‚ค์›Œ๋“œ๋Š” ํ•ด๋‹น ๋ณ€์ˆ˜ ํƒ€์ž…์˜ ๊ธฐ๋ณธ ๋˜๋Š” ๋นˆ ์ƒํƒœ๋ฅผ ๋ฐ˜ํ™˜ ์ฐธ์กฐ ํ˜•์‹(class, delegate, โ€ฆ)์˜ default ๊ฐ’: null ๊ฐ’ ํ˜•์‹ (struct, enum, โ€ฆ)์˜ default ๊ฐ’: all-zeroes value int 0, DateTime 0001-01-01 00:00:0...

Blittable & Unblittable

June 14 2021

Managed vs. Unmanaged Code Unmanaged code๋ž€ ์ปดํ“จํ„ฐ ๊ตฌ์กฐ, ํ”„๋กœ์„ธ์„œ์— ํŠนํ™”๋˜์–ด ๊ทธ์— ์˜์กดํ•˜๋Š” ์ฝ”๋“œ C#์—์„œ๋Š” unsafe ํ‚ค์›Œ๋“œ๋ฅผ ์ด์šฉํ•˜๋Š” ์ฝ”๋“œ ํ”„๋กœ๊ทธ๋ž˜๋จธ์— ์˜ํ•ด ์ง์ ‘ ๊ด€๋ฆฌ Managed code๋ž€ .NET ํ”„๋ ˆ์ž„์›Œํฌ์—์„œ ๊ตฌ๋™ํ•˜๋Š” C# ์ฝ”๋“œ ์ž์ฒด ...

lock ํ‚ค์›Œ๋“œ

June 04 2021

lock ํ‚ค์›Œ๋“œ ๊ฐœ์ฒด์— ๋Œ€ํ•œ ๋ฎคํ…์Šค๋ฅผ ํš๋“ํ•˜๊ณ  signal๊ณผ unlock์„ ์‹คํ–‰

sealed ํ‚ค์›Œ๋“œ

March 16 2021

sealed ํ‚ค์›Œ๋“œ ํด๋ž˜์Šค์— ์ ์šฉ๋œ ๊ฒฝ์šฐ ๋‹ค๋ฅธ ํด๋ž˜์Šค๊ฐ€ ํ•ด๋‹น ํด๋ž˜์Šค์—์„œ ์ƒ์†ํ•˜๋Š” ๊ฒƒ์„ ๋ง‰์Œ

unsafe ํ‚ค์›Œ๋“œ

March 15 2021

C# ํฌ์ธํ„ฐ C# ๋Œ€๋ถ€๋ถ„์˜ ์ฝ”๋“œ๋Š” ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” ์•ˆ์ „ํ•œ ์ฝ”๋“œ .Net ๋„๊ตฌ์—์„œ ์ฝ”๋“œ๊ฐ€ ์•ˆ์ „ํ•œ์ง€ ํ™•์ธ ๊ฐ€๋Šฅ ์›์‹œ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ํ• ๋‹นํ•˜์ง€ ์•Š๊ณ , ํฌ์ธํ„ฐ๋กœ ์ง์ ‘ ๋ฉ”๋ชจ๋ฆฌ์— ์—‘์„ธ์Šคํ•˜์ง€ ์•Š์Œ ๊ฒฝ์šฐ์— ๋”ฐ๋ผ ์•ฑ์˜ ์„ฑ๋Šฅ์„ ํ–ฅ์ƒ ํฌ์ธํ„ฐ๊ฐ€ ํ•„์š”ํ•œ ๋„ค์ดํ‹ฐ๋ธŒ ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๊ฒฝ์šฐ ํ•„์ˆ˜ ๋ณด์•ˆ ๋ฐ ์•ˆ์ „์„ฑ ์ด์Šˆ ๋ฐœ์ƒ...

async์™€ await ํ‚ค์›Œ๋“œ

March 12 2021

๋™๊ธฐ์™€ ๋น„๋™๊ธฐ ๋™๊ธฐ ์–ด๋–ค operation์„ ์‹คํ–‰์‹œ์ผฐ์„ ๋•Œ ๊ฒฐ๊ณผ๊ฐ’์ด ๋„์ถœ๋  ๋•Œ๊นŒ์ง€ ํ”„๋กœ๊ทธ๋žจ์€ ๋ฉˆ์ถฐ์„œ ๊ธฐ๋‹ค๋ ค์•ผ ํ•จ ๋น„๋™๊ธฐ ์–ธ์ œ ๊ฐ’์ด ๋„์ถœ๋  ์ง€ ๋ณด์žฅํ•  ์ˆ˜ ์—†๊ณ , ๊ทธ ๋™์•ˆ ํ”„๋กœ๊ทธ๋žจ์€ ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์Šค๋ฅผ ์ง„ํ–‰ํ•  ์ˆ˜ ์žˆ์Œ async / await๋Š” ์œ„ ์ค‘ ๋น„๋™๊ธฐ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ์œ„ํ•ด ์‚ฌ...

Extension Method

March 08 2021

ํ™•์žฅ ๋ฉ”์„œ๋“œ๋ž€ ๊ธฐ์กด ์ œ๊ณต๋˜๋Š” ํด๋ž˜์Šค/๊ตฌ์กฐ์ฒด/์ธํ„ฐํŽ˜์ด์Šค์˜ ๊ตฌํ˜„์„ ์ง์ ‘ ๋ณ€๊ฒฝํ•˜์ง€ ์•Š๊ณ  ๊ธฐ๋Šฅ์„ ํ™•์žฅํ•ด ์‚ฌ์šฉ ๊ธฐ์กด ๋ฐ์ดํ„ฐ ํƒ€์ž… (int, float ๋“ฑ)์˜ class์—๋„ ์ ์šฉ ๊ฐ€๋Šฅ

Nullable and Tenary

February 22 2021

๋ฌผ์Œํ‘œ ์—ฐ์‚ฐ์ž ๋‘๊ฐœ๊ฐ€ ์—ฐ์†์ ์œผ๋กœ ์“ฐ์ด๋Š” ์˜ˆ์‹œ

Auto Property

February 22 2021

Property ์ •๋ณด์€๋‹‰์„ ๋” ๊ฐ„๊ฒฐํ•˜๊ณ  ๊ฐ„๋‹จํ•˜๊ฒŒ ๊ตฌํ˜„ํ•˜๋„๋ก ํ—ˆ์šฉ get / set ๋ฉ”์„œ๋“œ๋ฅผ ๋Œ€์‹ ํ•ด ๊ฐ€๋…์„ฑ์„ ๋ณด์™„

partial ํ‚ค์›Œ๋“œ

February 19 2021

partial ํ‚ค์›Œ๋“œ C#์—์„œ๋Š” C/C++์™€ ๋‹ฌ๋ฆฌ cs ํŒŒ์ผ ํ•˜๋‚˜์— ํด๋ž˜์Šค ์„ ์–ธ๊ณผ ์ •์˜๊ฐ€ ์ž‘์„ฑ ํด๋ž˜์Šค๊ฐ€ ์ปค์งˆ ๊ฒฝ์šฐ ๊ฐ€๋…์„ฑ์ด ๋–จ์–ด์ง Partial ํ‚ค์›Œ๋“œ๋ฅผ ์ œ๊ณตํ•จ์œผ๋กœ์จ ์—ฌ๋Ÿฌ ํŒŒ์ผ์— ํ•˜๋‚˜์˜ ํด๋ž˜์Šค๋ฅผ ์ž‘์„ฑํ•˜๋„๋ก ํ—ˆ์šฉ ๋Œ€๋ฆฌ์ž(delegate) ๋˜๋Š” ์—ด๊ฑฐํ˜•(enum) ์„ ์–ธ์„ ํ•  ๋•Œ partial ํ•œ์ •์ž๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Œ ```csharp /...

C# parameter modifier

February 19 2021

in ํ‚ค์›Œ๋“œ in ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ „๋‹ฌ๋˜๋Š” ๋ณ€์ˆ˜๋Š” ๋ฉ”์„œ๋“œ๋กœ ์ „๋‹ฌ๋˜๊ธฐ ์ „ ๋ฐ˜๋“œ์‹œ ์ดˆ๊ธฐํ™” ์ธ์ˆ˜๊ฐ€ ์ฐธ์กฐ๋กœ ์ „๋‹ฌ๋˜์ง€๋งŒ, ์ˆ˜์ •๋˜์ง€ ์•Š์Œ ์˜ค๋ฒ„๋กœ๋”ฉ ๊ทœ์น™ ```csharp class InOverloads { // ์˜ค๋ฒ„๋กœ๋”ฉ ํ—ˆ์šฉ public void SampleMethod(in int i) { } public void SampleMeth...

C#์—์„œ byte์™€ char์˜ ์ฐจ์ด

February 19 2021

byte์™€ char์˜ ์‚ฌ์ด์ฆˆ byte: 1๋ฐ”์ดํŠธ ์ˆซ์ž ์ž๋ฃŒํ˜• char: 2๋ฐ”์ดํŠธ ๋ฌธ์ž ์ž๋ฃŒํ˜• 1๋ฐ”์ดํŠธ ์•„๋‹˜! ๋Œ€๋ถ€๋ถ„์˜ .Net ์–ธ์–ด์˜ ๋ฌธ์ž์—ด์€ ์œ ๋‹ˆ์ฝ”๋“œ utf-16์„ ๋””ํดํŠธ๋กœ ์ง€์›

var ํ‚ค์›Œ๋“œ

February 17 2021

var ์•”์‹œ์  ํ˜•์‹ ์ปดํŒŒ์ผ๋Ÿฌ๊ฐ€ compile time์— ์ž๋ฃŒํ˜•์„ ๊ฒฐ์ • ์ œ์•ฝ ์กฐ๊ฑด ์ง€์—ญ ๋ณ€์ˆ˜์—๋งŒ ์‚ฌ์šฉ ๊ฐ€๋Šฅ ๋ณ€์ˆ˜ ์„ ์–ธ๊ณผ ํ•จ๊ป˜ ์ดˆ๊ธฐํ™” ํ•„์ˆ˜ null / ์ต๋ช… ๋ฉ”์„œ๋“œ / ๋ฉ”์„œ๋“œ ๊ทธ๋ฃน์œผ๋กœ ์ดˆ๊ธฐํ™” ๋ถˆ๊ฐ€

Dictionary

February 17 2021

Dictionary์˜ ์ข…๋ฅ˜ Dictionary Key์™€ Value์˜ Pair๋ฅผ ๊ฐ–๋Š” ์ž๋ฃŒ๊ตฌ์กฐ Generic ํ•ด์‹œํ…Œ์ด๋ธ” ๊ตฌ์กฐ๋ฅผ ์‚ฌ์šฉ

Reflection & Attribute

February 17 2021

๋ฆฌํ”Œ๋ ‰์…˜์˜ ๊ฐœ๋… ์ผ๋ฐ˜์ ์œผ๋กœ๋Š” ํด๋ž˜์Šค๋ฅผ ํ†ตํ•ด ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑ ์‚ฌ์šฉ์ž(ํ”„๋กœ๊ทธ๋ž˜๋จธ)๋Š” ํด๋ž˜์Šค์˜ ํ•„๋“œ์™€ ๋ฉ”์„œ๋“œ๋ฅผ ์•Œ๊ณ  ์žˆ๊ณ , ์‚ฌ์šฉํ•˜๋Š” ๋ฐ ๋ถˆํŽธํ•จ์ด ์—†๋‹ค

as & is ํ‚ค์›Œ๋“œ

February 17 2021

as์™€ is ํ˜•๋ณ€ํ™˜์„ ์œ„ํ•œ ์˜ˆ์•ฝ์–ด ๊ฐœ๋ฐœ์ž์— ์˜ํ•ด์„œ ์˜๋„์ ์œผ๋กœ downcastingํ•˜๋„๋ก ๋„์™€์ฃผ๋Š” ์—ฐ์‚ฐ์ž downcasting ๋ฒ ์ด์Šค ํด๋ž˜์Šค๊ฐ€ ํŒŒ์ƒ ํด๋ž˜์Šค๋กœ ์บ์ŠคํŒ… ๋˜๋Š” ๊ฒƒ upcasting ํŒŒ์ƒ ํด๋ž˜์Šค๊ฐ€ ๋ฒ ์ด์Šค ํด๋ž˜์Šค๋กœ ์บ์ŠคํŒ… ๋˜๋Š” ๊ฒƒ

new ํ‚ค์›Œ๋“œ

February 15 2021

๋ฉ”์„œ๋“œ์— ์„ ์–ธ๋œ new modifier base class์˜ ๋ฉ”์„œ๋“œ๋ฅผ ์ˆจ๊น€ upcasting ํ•˜์—ฌ base class์˜ ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์œผ๋‚˜ ์ด๋Š” ์˜๋„๋œ ๋””์ž์ธ์— ๋ฐ˜ํ•˜๋Š” ํ–‰์œ„์ด๋ฏ€๋กœ ์œ„ํ—˜

delegate ํ‚ค์›Œ๋“œ

February 15 2021

delegate(๋Œ€๋ฆฌ์ž) ํ‚ค์›Œ๋“œ delegate๋Š” ๋ฉ”์„œ๋“œ๋ฅผ ๋‹ค๋ฅธ ๋ฉ”์„œ๋“œ์— ์ธ์ˆ˜๋กœ ์ „๋‹ฌํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ ํ˜•์‹์ด ์ผ์น˜ํ•˜๋Š” ๊ตฌ์กฐ์˜ ๋ชจ๋“  ๋ฉ”์„œ๋“œ๋Š” ๋Œ€๋ฆฌ์ž์— ํ• ๋‹นํ•  ์ˆ˜ ์žˆ๋‹ค ๋ฉ”์„œ๋“œ๋Š” ์ •์ /์ธ์Šคํ„ด์Šค์ผ ์ˆ˜ ์žˆ๋‹ค. delegate ์†์„ฑ ํ•จ์ˆ˜ ํฌ์ธํ„ฐ์™€ ์œ ์‚ฌํ•˜์ง€๋งŒ, ๊ฐ์ฒด ์ง€ํ–ฅ์ ์œผ๋กœ ์ธ์Šคํ„ด์Šค ๋ฐ ๋ฉ”์„œ๋“œ๋ฅผ ์บก์Šํ™”ํ•œ๋‹ค. ๋ฉ”์„œ๋“œ๋ฅผ ๋งค๊ฐœ ๋ณ€์ˆ˜๋กœ ์ „๋‹ฌํ•  ์ˆ˜ ...

interface vs. abstract

January 19 2020

interface ํŠน์ • ๋ฉ”์„œ๋“œ๋“ค์˜ ์กฐํ•ฉ์„ ๊ณ ๋ ค