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

# · C# · 43 lines · 33 code · 10 blank · 0 comment · 0 complexity · 9d473cb309f173c32c7fecb90c3ef12a MD5 · raw file

  1. using System;
  2. public class runme
  3. {
  4. static void Main()
  5. {
  6. int[] source = { 1, 2, 3 };
  7. int[] target = new int[ source.Length ];
  8. example.myArrayCopy( source, target, target.Length );
  9. Console.WriteLine( "Contents of copy target array using default marshaling" );
  10. PrintArray( target );
  11. target = new int[ source.Length ];
  12. example.myArrayCopyUsingFixedArrays( source, target, target.Length );
  13. Console.WriteLine( "Contents of copy target array using fixed arrays" );
  14. PrintArray( target );
  15. target = new int[] { 4, 5, 6 };
  16. example.myArraySwap( source, target, target.Length );
  17. Console.WriteLine( "Contents of arrays after swapping using default marshaling" );
  18. PrintArray( source );
  19. PrintArray( target );
  20. source = new int[] { 1, 2, 3 };
  21. target = new int[] { 4, 5, 6 };
  22. example.myArraySwapUsingFixedArrays( source, target, target.Length );
  23. Console.WriteLine( "Contents of arrays after swapping using fixed arrays" );
  24. PrintArray( source );
  25. PrintArray( target );
  26. }
  27. static void PrintArray( int[] a )
  28. {
  29. foreach ( int i in a )
  30. Console.Write( "{0} ", i );
  31. Console.WriteLine();
  32. }
  33. }