[C#] ๊น์๋ณต์ฌ ์์๋ณต์ฌ, readonly, ๊ตฌ์กฐ์ฒด, ํํ
๊น์ ๋ณต์ฌ/์์ ๋ณต์ฌ ์์ ๋ณต์ฌ(Shallow Copy): ๋์ผํ ๋ฉ๋ชจ๋ฆฌ ์ฃผ์๋ฅผ ๊ณ ์ ํจ -> ๊ฐ์ด ๋ณํจ using System; class Program { static void Main() { int[] originalArray = { 1, 2, 3 }; int[] shallowCopyArray = (int[])originalArray.Clone(); shallowCopyArray[0] = 99; Console.WriteLine("Original Array: " + string.Join(", ", originalArray)); // ์ถ๋ ฅ: Original Array: 1, 2, 3 Console.WriteLine("Shallow Copy Array: " + string.Join(", ", shallow..
2023. 8. 17.
[C#] ์ฐธ์กฐ ๋งค๊ฐ๋ณ์ ์ ๋ฌ, ์ฌ๋ฌ ๊ฐ์ ๊ฐreturn, ๊ฐ๋ณ ๊ฐ์์ ์ธ์, ์ ํ์ ์ธ์
์ฐธ์กฐ์ ์ํ ๋งค๊ฐ๋ณ์ ์ ๋ฌ ๋ณดํต ๋ค๋ฅธ ๋ฉ์๋์ ์ธ์๋ฅผ ์ ๋ฌํ ๋, ๋ฐ์ดํฐ๊ฐ ๋ณต์ฌ๋์ด์ ์ ๋ฌ๋๋ค. ๋ง์ฝ ์ฃผ์๊ฐ์ ๋ณด๋ด๊ณ ์ถ๋ค๋ฉด ์์ ref๋ฅผ ๋ถ์ฌ์ฃผ๋ฉด ๋๋ค. class Program { public static void Main(string[] args) { int x = 3; int y = 4; Console.WriteLine($"x = {x}, y = {y}"); Swap(x, y); Console.WriteLine($"x = {x}, y = {y}"); SwapRef(ref x, ref y); Console.WriteLine($"x = {x}, y = {y}"); } static void Swap(int a, int b) { int temp = b; b = a; a = temp; } static vo..
2023. 8. 16.
");
wcs_do();