반응형


[GetUpperBound, GetLowerBound]




구문 소개에 앞서 배열 차원 인덱스 반환 함수 설명 (차원 숫자가 클 수록 더 안쪽에 있는 차원을 말한다)

public int GetUpperBound(
	int dimension
)

GetUpperBound(0)배열의 첫 번째 차원에서 마지막 인덱스를 반환 하 고 GetUpperBound(Rank - 1) 마지막 배열의 마지막 차원 인덱스를 반환 합니다.






Copy(Array, Array, Int32)  : 인자들은 첫번째 배열, 두번째 인자, 마지막 숫자는 인덱스 위치까지 복사될 index

System_CAPS_pubmethodSystem_CAPS_staticCopy(Array, Array, Int32)

Array의 요소 범위를 첫 번째 요소부터 복사하여 다른 Array에 첫 번째 요소부터 붙여넣습니다. 길이가 32비트 정수로 지정되어 있습니다.

System_CAPS_pubmethodSystem_CAPS_staticCopy(Array, Array, Int64)

Array의 요소 범위를 첫 번째 요소부터 복사하여 다른 Array에 첫 번째 요소부터 붙여넣습니다. 길이가 64비트 정수로 지정되어 있습니다.

System_CAPS_pubmethodSystem_CAPS_staticCopy(Array, Int32, Array, Int32, Int32)

Array의 요소 범위를 지정한 소스 인덱스부터 복사하여 지정된 대상 인덱스부터 시작하는 다른 Array에 붙여 넣습니다. 길이와 인덱스가 32비트 정수로 지정되어 있습니다.

System_CAPS_pubmethodSystem_CAPS_staticCopy(Array, Int64, Array, Int64, Int64)

Array의 요소 범위를 지정한 소스 인덱스부터 복사하여 지정된 대상 인덱스부터 시작하는 다른 Array에 붙여 넣습니다. 길이와 인덱스가 64비트 정수로 지정되어 있습니다.

System_CAPS_pubmethodCopyTo(Array, Int32)

현재 1차원 배열의 모든 요소를 지정된 대상 배열 인덱스부터 시작하여 지정된 1차원 배열에 복사합니다. 인덱스가 32비트 정수로 지정되어 있습니다.

System_CAPS_pubmethodCopyTo(Array, Int64)

현재 1차원 배열의 모든 요소를 지정된 대상 배열 인덱스부터 시작하여 지정된 1차원 배열에 복사합니다. 인덱스가 64비트 정수로 지정되어 있습니다.



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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
public class SamplesArray
{
 
    public static void Main()
    {
 
        // Creates and initializes a new integer array and a new Object array.
        int[] myIntArray = new int[5] { 12345 };
        Object[] myObjArray = new Object[5] { 2627282930 };
 
        // Prints the initial values of both arrays.
        Console.WriteLine("Initially,");
        Console.Write("integer array:");
        PrintValues(myIntArray);
        Console.Write("Object array: ");
        PrintValues(myObjArray);
 
        // Copies the first two elements from the integer array to the Object array.
        System.Array.Copy(myIntArray, myObjArray, 2); //처음 두개만 복사
 
        // Prints the values of the modified arrays.
        Console.WriteLine("\nAfter copying the first two elements of the integer array to the Object array,");
        Console.Write("integer array:");
        PrintValues(myIntArray);
        Console.Write("Object array: ");
        PrintValues(myObjArray);
 
        // Copies the last two elements from the Object array to the integer array.
//마지막 두개 복사
        System.Array.Copy(myObjArray, myObjArray.GetUpperBound(0- 1, myIntArray, myIntArray.GetUpperBound(0- 12);
 
        // Prints the values of the modified arrays.
        Console.WriteLine("\nAfter copying the last two elements of the Object array to the integer array,");
        Console.Write("integer array:");
        PrintValues(myIntArray);
        Console.Write("Object array: ");
        PrintValues(myObjArray);
    }
 
 
    public static void PrintValues(Object[] myArr)
    {
        foreach (Object i in myArr)
        {
            Console.Write("\t{0}", i);
        }
        Console.WriteLine();
    }
 
    public static void PrintValues(int[] myArr)
    {
        foreach (int i in myArr)
        {
            Console.Write("\t{0}", i);
        }
        Console.WriteLine();
    }
}
/* 
This code produces the following output.
Initially,
integer array:  1       2       3       4       5
Object array:   26      27      28      29      30
After copying the first two elements of the integer array to the Object array,
integer array:  1       2       3       4       5
Object array:   1       2       28      29      30
After copying the last two elements of the Object array to the integer array,
integer array:  1       2       3       29      30
Object array:   1       2       28      29      30
*/
 

cs



ref : https://msdn.microsoft.com/ko-kr/library/system.array(v=vs.110).aspx

반응형

+ Recent posts