[C#] ref (참조 매개변수 전달)


[C#] ref (참조 매개변수 전달)

ref 사용방법입니다. 기존의 C는 주소참조를 하려면 &를 붙여야 했습니다. *와 &에 대한 포인터 개념이 포인터에 포인터를 물고 포인터가 더해지면 아주 끝장나죠.... 그래서 C#에서는 ref 라는 키워드를 써서 직관적으로 만든것 같습니다. Colored By Color Scripter 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ref_test { class Program { static void Main(string[] args) { int x = 1; int y = 2; Console.WriteLine("x:{0} y:{0}", x, y); Swap(...


#IT·컴퓨터

원문링크 : [C#] ref (참조 매개변수 전달)