강의

멘토링

커뮤니티

Inflearn Community Q&A

asd8888771554's profile image
asd8888771554

asked

[MMORPG Game Development Series with C# and Unity] Part 1: Introduction to Basic C# Programming

ref, out

너무 어리석은 로직 같지만 ㅠ

Written on

·

361

0

  •  internal class Program
        {
            static int Swap(ref int a, ref int b)
            {
                a = b;
                b = 1;
               return a & b;
              
            }

            static void Main(string[] args)
            {
                int num1 = 1;
                int num2 = 2;
                Program.Swap(ref num1, ref num2);
                Console.WriteLine($"{num1},{num2}");

3:39초 한번해보라해서 했는데 엉망인가요

C#

Answer 2

0

asd8888771554님의 프로필 이미지
asd8888771554
Questioner

알려주셔서 감사합니다 ㅠ

 

결과만 도출하려는데만 급급했습니다 ㅠ

0

Rookiss님의 프로필 이미지
Rookiss
Instructor

b =1 의 의미는 무엇일까요?

num1이 1이라서 1을 넣으신거라면, 일종의 하드코딩입니다.
num1, num2가 무슨 값인지는 함수 안에서는 전혀 모르는 상태이기 때문이죠.

asd8888771554's profile image
asd8888771554

asked

Ask a question