스터디 1팀 3주차 (4월 04일) - DevOpsSociety/Study1team GitHub Wiki

3주차 (4월 04일)

1. 객체지향과 절차지향의 차이

2. 접근제한자

  • public

    • 어디서든 접근 가능
    • 주로 API 또는 외부에서 사용되어야 하는 클래스나 메서드에 사용
  • private

    • 오직 클래스 내부에서만 접근 가능
    • 기본값이며, 가장 폐쇄적인 형태
  • protected

    • 클래스 내부 + 상속받은 클래스에서 접근 가능
    • 외부에서는 직접 접근 불가
  • internal

    • 같은 어셈블리(프로젝트) 내에서만 접근 가능
    • 다른 프로젝트에서 참조할 경우 접근 불가
  • protected internal

    • 같은 어셈블리이거나, 상속을 받은 경우 접근 가능

3. 진행 관련 방향 토의

4. 진행 시간 및 장소

  • 4월 04일 금요일 오후 8시 디스코드를 통한 온라인 스터디 진행 (장소와 시간은 변동사항 생기면 수정)

C# 기본 형태

using System;

namespace _ex250328
{
    internal class Program
    {
        static void Main(string[] args) // = int main(){}
        {
            Console.WriteLine("Hello World!");
        }
    }
}

과제

(과제에 대한 답은 다음 주 스터디가 시작하면 답을 단톡방에 올려주세요. 모두 같이 맞춰보겠습니다! 특별 문제는 못 맞추셔도 다른 문제들은 꼭 맞추어주세요ㅠㅠ!)

  1. x값을 바꾸고 싶어서 x 값을 수정해봤습니다. 옳은 코드인가요?
using System;
namespace _3주차_과제
{
    class Point
    {
        private int x;
        private int y;
        public Point(int _x, int _y)
        {
            this.x = _x;
            this.y = _y;
        }
        public void Print()
        {
            Console.WriteLine($"({x}, {y})");
        }

    }
    internal class Program
    {
        static void Main(string[] args)
        {
            Point pt = new Point(1, 1);
            pt.x = 49;
            pt.Print();
        }
    }
}
  1. 두 코드의 차이점이 뭘까요? (출력값은 (1, 1)로 상동합니다.)
using System;
namespace _3주차_과제
{
    class Point
    {
        private int x;
        private int y;
        public Point(int _x, int _y)
        {
            this.x = _x;
            this.y = _y;
        }
        public void Print()
        {
            Console.WriteLine($"({x}, {y})");
        }

    }
    internal class Program
    {
        static void Main(string[] args)
        {
            Point pt = new Point(1, 1);
            pt.Print();
        }
    }
}
using System;
namespace _3주차_과제
{
    class Point
    {
        public int x;
        public int y;
        public Point(int _x, int _y)
        {
            this.x = _x;
            this.y = _y;
        }
        public void Print()
        {
            Console.WriteLine($"({x}, {y})");
        }

    }
    internal class Program
    {
        static void Main(string[] args)
        {
            Point pt = new Point(1, 1);
            pt.Print();
        }
    }
}
  1. ⭐특별문제⭐

(특별 문제는 제가 추가적으로 공부하면서 만드는 문제들입니다. 고로 C#을 벗어날 수도 있기에 못 맞추셔도 괜찮습니다.)

Unity에서 private 필드임에도 불구하고 Inspector에 노출되어 값을 수정할 수 있게 만들어주는 속성은 무엇일까요?


스터디 사진

image