1
- // <Snippet1>
1
+ // <Snippet1>
2
2
using System ;
3
3
public class SamplesArray {
4
4
5
5
public static void Main ( ) {
6
6
7
- // Creates and initializes a new Array of type Int32 .
7
+ // Creates and initializes a new Array of type int .
8
8
Array myIntArray = Array . CreateInstance ( typeof ( System . Int32 ) , 5 ) ;
9
9
for ( int i = myIntArray . GetLowerBound ( 0 ) ; i <= myIntArray . GetUpperBound ( 0 ) ; i ++ )
10
10
myIntArray . SetValue ( i + 1 , i ) ;
@@ -15,21 +15,21 @@ public static void Main() {
15
15
myObjArray . SetValue ( i + 26 , i ) ;
16
16
17
17
// Displays the initial values of both arrays.
18
- Console . WriteLine ( "Int32 array:" ) ;
18
+ Console . WriteLine ( "int array:" ) ;
19
19
PrintValues ( myIntArray ) ;
20
20
Console . WriteLine ( "Object array:" ) ;
21
21
PrintValues ( myObjArray ) ;
22
22
23
- // Copies the first element from the Int32 array to the Object array.
23
+ // Copies the first element from the int array to the Object array.
24
24
Array . Copy ( myIntArray , myIntArray . GetLowerBound ( 0 ) , myObjArray , myObjArray . GetLowerBound ( 0 ) , 1 ) ;
25
25
26
- // Copies the last two elements from the Object array to the Int32 array.
26
+ // Copies the last two elements from the Object array to the int array.
27
27
Array . Copy ( myObjArray , myObjArray . GetUpperBound ( 0 ) - 1 , myIntArray , myIntArray . GetUpperBound ( 0 ) - 1 , 2 ) ;
28
28
29
29
// Displays the values of the modified arrays.
30
- Console . WriteLine ( "Int32 array - Last two elements should now be the same as Object array:" ) ;
30
+ Console . WriteLine ( "int array - Last two elements should now be the same as Object array:" ) ;
31
31
PrintValues ( myIntArray ) ;
32
- Console . WriteLine ( "Object array - First element should now be the same as Int32 array:" ) ;
32
+ Console . WriteLine ( "Object array - First element should now be the same as int array:" ) ;
33
33
PrintValues ( myObjArray ) ;
34
34
}
35
35
@@ -52,13 +52,13 @@ public static void PrintValues( Array myArr ) {
52
52
/*
53
53
This code produces the following output.
54
54
55
- Int32 array:
55
+ int array:
56
56
1 2 3 4 5
57
57
Object array:
58
58
26 27 28 29 30
59
- Int32 array - Last two elements should now be the same as Object array:
59
+ int array - Last two elements should now be the same as Object array:
60
60
1 2 3 29 30
61
- Object array - First element should now be the same as Int32 array:
61
+ Object array - First element should now be the same as int array:
62
62
1 27 28 29 30
63
63
*/
64
64
// </Snippet1>
0 commit comments