PageRenderTime 37ms CodeModel.GetById 31ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/csharp/arrays/runme.cs

#
C# | 43 lines | 33 code | 10 blank | 0 comment | 0 complexity | 9d473cb309f173c32c7fecb90c3ef12a MD5 | raw file
 1using System;
 2
 3public class runme
 4{
 5  static void Main() 
 6  {
 7    int[] source = { 1, 2, 3 };
 8    int[] target = new int[ source.Length ];
 9
10    example.myArrayCopy( source, target, target.Length );
11          
12    Console.WriteLine( "Contents of copy target array using default marshaling" );
13    PrintArray( target );
14
15    target = new int[ source.Length ];
16    
17    example.myArrayCopyUsingFixedArrays( source, target, target.Length );
18    Console.WriteLine( "Contents of copy target array using fixed arrays" );
19    PrintArray( target );
20
21    target = new int[] { 4, 5, 6 };
22    example.myArraySwap( source, target, target.Length );
23    Console.WriteLine( "Contents of arrays after swapping using default marshaling" );
24    PrintArray( source );
25    PrintArray( target );
26    
27    source = new int[] { 1, 2, 3 };
28    target = new int[] { 4, 5, 6 };
29    
30    example.myArraySwapUsingFixedArrays( source, target, target.Length );
31    Console.WriteLine( "Contents of arrays after swapping using fixed arrays" );
32    PrintArray( source );
33    PrintArray( target );
34  }
35  
36  static void PrintArray( int[] a ) 
37  {
38    foreach ( int i in a ) 
39      Console.Write( "{0} ", i );
40    Console.WriteLine();
41  }
42}
43