맴버변수 ?

 

클래스에 정의된 변수

맴버변수는 인스턴스가 메모리에 있는동안 접근 가능

 

지역변수?

메서드에 정의된 변수

메서드가 실행되는 동안 접근 가능

https://www.youtube.com/watch?v=tR376tcsgag&list=PLTFRwWXfOIYBmr3fK17E0VhKPyYrGy75z&index=32

 

https://www.youtube.com/watch?v=tR376tcsgag&list=PLTFRwWXfOIYBmr3fK17E0VhKPyYrGy75z&index=32
https://www.youtube.com/watch?v=tR376tcsgag&list=PLTFRwWXfOIYBmr3fK17E0VhKPyYrGy75z&index=32
https://www.youtube.com/watch?v=tR376tcsgag&list=PLTFRwWXfOIYBmr3fK17E0VhKPyYrGy75z&index=32
https://www.youtube.com/watch?v=tR376tcsgag&list=PLTFRwWXfOIYBmr3fK17E0VhKPyYrGy75z&index=32

 

가비지 컬렉션?

메모리를 자동으로 관리해주는 메커니즘

 

https://www.youtube.com/watch?v=tR376tcsgag&list=PLTFRwWXfOIYBmr3fK17E0VhKPyYrGy75z&index=32
https://www.youtube.com/watch?v=tR376tcsgag&list=PLTFRwWXfOIYBmr3fK17E0VhKPyYrGy75z&index=32
https://www.youtube.com/watch?v=tR376tcsgag&list=PLTFRwWXfOIYBmr3fK17E0VhKPyYrGy75z&index=32

 

https://www.youtube.com/watch?v=tR376tcsgag&list=PLTFRwWXfOIYBmr3fK17E0VhKPyYrGy75z&index=32

 

null은 참조하지 않음

 

https://www.youtube.com/watch?v=tR376tcsgag&list=PLTFRwWXfOIYBmr3fK17E0VhKPyYrGy75z&index=32
https://www.youtube.com/watch?v=tR376tcsgag&list=PLTFRwWXfOIYBmr3fK17E0VhKPyYrGy75z&index=32

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Step32
{
    internal class Car
    {
        public string name;
        public float speed;
        public Car(string carName)
        {
            name = carName;
            Console.WriteLine("{0}이(가) 자동차가 생성되었습니다", carName);
        }

        public void Move(float moveSpeed)
        {
            speed = moveSpeed;
            Console.WriteLine("{0}속도로 이동합니다", moveSpeed);
        }
    }
}

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Step32
{
    internal class Car
    {
        public string name;
        public float speed;
        public Car(string carName)
        {
            name = carName;
            Console.WriteLine("{0}이(가) 자동차가 생성되었습니다", carName);
        }

        public void Move(float moveSpeed)
        {
            speed = moveSpeed;
            Console.WriteLine("{0}속도로 이동합니다", moveSpeed);
        }
    }
}

 

'Study > C#' 카테고리의 다른 글

[C#] this 키워드  (0) 2024.05.31
[C#] 점연산자 NullReferenceException  (0) 2024.05.30
[C#] 생성자 메서드  (0) 2024.05.29
[C#] 클래스와 new 연산자  (0) 2024.05.29
[C#]메서드 반환타입  (0) 2024.05.28

+ Recent posts