C#

C# 소스코드: Call By Reference,Value 인수 전달 방식

드린 2017. 1. 1. 23:29
반응형
using System;  
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyNamespace
{
    
    class MyClass
    {
        public static void Swap(ref int x, ref int y)
        {
            int temp;
            temp = x;
            x = y;
            y = temp;
        }
        public static void Main(string[] args)
        {
            int one = 1;
            int two = 2;

            Console.WriteLine("Before one=" + one + " two=" + two);
            Swap(ref one, ref two);

            Console.WriteLine("After one=" + one + " two=" + two);
        }
    }
}

<결과>

2017/01/01 - [C#] - C# 소스코드: 자료형 변환 예제

2017/01/01 - [C#] - C# 소스코드: 박싱, 언박싱 사용예제

2017/01/01 - [C#] - C# 소스코드: object 데이터 타입 사용예제

#C# #C# 소스코드 #Call By Reference,Value 인수 전달 방식 #실습 예제

반응형