
2016-12-31
2016-12-30
2016-12-29
C# - 배열 복사(Array Copy)
* C# 배열 복사(Array Copy)
- System.Array.Copy()와 Clone()은 CopyTo()와 같은 메소드가 있다.레퍼런스 형태의 복사가 아니고 독립적인 메모리에 값을 설정합니다.
int[] src = new int[4] { 14, 15, 16, 17 };
int[] dstCopy = new int[4];
int[] dstCopyTo = new int[4];
int[] dstClone;
// 앞 2개의 값을 복사, 일부를 복사할 경우 사용
System.Array.Copy(src, dstCopy, 2);
// 목표 배열에 2번째 인덱스 부터 복사, 메모리 익셉션 주의
src.CopyTo(dstCopyTo, 2);
// 모든 항목을 복사(메모리를 할당)
dstClone = (int[])src.Clone();
- System.Array.Copy()와 Clone()은 CopyTo()와 같은 메소드가 있다.레퍼런스 형태의 복사가 아니고 독립적인 메모리에 값을 설정합니다.
int[] src = new int[4] { 14, 15, 16, 17 };
int[] dstCopy = new int[4];
int[] dstCopyTo = new int[4];
int[] dstClone;
// 앞 2개의 값을 복사, 일부를 복사할 경우 사용
System.Array.Copy(src, dstCopy, 2);
// 목표 배열에 2번째 인덱스 부터 복사, 메모리 익셉션 주의
src.CopyTo(dstCopyTo, 2);
// 모든 항목을 복사(메모리를 할당)
dstClone = (int[])src.Clone();
2016-12-27
2016-12-25
2016-12-22
2016-12-20
2016-12-18
2016-12-17
2016-12-16
2016-12-11
2016-12-08
2016-12-05
2016-12-04
2016-12-03
2016-12-01
피드 구독하기:
글 (Atom)