πŸ“ Language/✏ C#

    [C#] ref와 out ν‚€μ›Œλ“œ

    ref와 out ν‚€μ›Œλ“œ ref와 out ν‚€μ›Œλ“œλŠ” 인자둜 λ„˜κΈ΄ λ³€μˆ˜λ₯Ό λ©”μ„œλ“œ λ‚΄λΆ€μ—μ„œ μ°Έμ‘° ν˜•νƒœλ‘œ μ‚¬μš©ν•œλ‹€λŠ” μ μ—μ„œ λ™μΌν•˜λ‹€. 속성(Property)은 λ³€μˆ˜κ°€ μ•„λ‹ˆλ―€λ‘œ 전달할 수 μ—†λ‹€. using System; namespace Test { class Program { static void Main(string[] args) { int i = 0; foo(ref i); Console.WriteLine(i); int j; bar(out j); Console.WriteLine(j); } static void foo(ref int a) { a = 3; } static void bar(out int a) { a = 15; } } } // 3 // 15 κ·ΈλŸ¬λ‚˜ 두 ν‚€μ›Œλ“œλ„ 차이점은 μžˆλ‹€. refλŠ” 인자둜 μ „λ‹¬ν•˜κΈ° ..