Notice
Recent Posts
Recent Comments
Link
반응형
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 깊이탐색
- Simulation
- dropdown
- sparkmain(clone) 무한생성
- 디지털트윈
- 유니티 sparkmain(clone)
- Unity
- GetComponent
- dfs
- 크루스칼
- 행동트리
- navisworks api
- 너비탐색
- 습관형성 #직장인자기계발 #오공완
- 최소신장트리 mst
- articulation body
- unity sparkmain(clone)
- 유니티
- readonly
- removeAll
- 오블완
- list clear
- unity korea
- 드롭다운
- 트리구조
- raycast
- 티스토리챌린지
- sparkmain(clone)
- C#
- 최단거리 알고리즘
Archives
- Today
- Total
낑깡의 게임 프로그래밍 도전기
C# static, deepcopy 본문
반응형
static
스태틱은 인스턴트 선언 없이 바로 접근 가능
인스턴스로 만들어진 것 과는 차이가 있다
인스턴스는 범위내에서만 쓸수있고 스태틱은 수동으로 초기화해주기전까진 시스템이 끝날때까지 살아있다.
그래서 스태틱을 쓰면 다 기억을 하고있어야함
deepcapy
클래스와 큰 연관이 있음
주소만 복사하는 것을 쉘로우카피라고 한다.
internal class ActorBase
{
public string Name { get; protected set; }
public string Description { get; protected set; }
public ActorBase(string name)
{
Name = name;
}
public ActorBase DeepCopy()
{
ActorBase actorBase = new ActorBase(name);
actorBase.Description = this.Description;
return actorBase;
}
public virtual void AddName(string value)
{
this.Name = Name + value;
}
}
예전부터 사용한 고전방식으로 카피
인터페이스 중 ICloneable이 있다
public object Clone()
{
return this.MemberwiseClone();//복제
}
너무 복잡한 멤버변수를 들고있다면 구조가 복잡하다면 간혹 복사가 안되는 경우가 있다. 그래서 잘 복제 됬는지 확인 하는게 중요하다.
반응형
'C#' 카테고리의 다른 글
| C# 람다식(Lamba) (0) | 2025.07.25 |
|---|---|
| C# 서브클래스, 인터페이스, 추상클래스 (1) | 2025.07.24 |
| C# 의존성 주입(Dependency Injection, DI) (1) | 2025.07.22 |
| C# 상속 (Up, Down casting), as is (0) | 2025.07.21 |
| C# 클래스 : 생성자, readonly, 한정자, this (0) | 2025.07.20 |