fork download
  1. using System;
  2. using System.Diagnostics;
  3. using System.Linq;
  4.  
  5. namespace ProgramConsole
  6. {
  7. public class Program
  8. {
  9. public static void Main(string[] args)
  10. {
  11. // Create an ArraySegment from this array.
  12. int[] ourarray = { 15, 25, 35 };
  13. ArraySegment<int> newsegment = new ArraySegment<int>(ourarray, 1, 2);
  14.  
  15. // Write the array.
  16. Console.WriteLine("-- Array --");
  17. int[] original = newsegment.Array;
  18. foreach ( int value in original )
  19. {
  20. Console.WriteLine(value);
  21. }
  22.  
  23. // Write the offset.
  24. Console.WriteLine("-- Offset --");
  25. Console.WriteLine(newsegment.Offset);
  26.  
  27. // Write the count.
  28. Console.WriteLine("-- Count --");
  29. Console.WriteLine(newsegment.Count);
  30.  
  31. // Write the elements in the range specified in the ArraySegment.
  32. Console.WriteLine("-- Range --");
  33. for ( int i = newsegment.Offset; i <= newsegment.Count; i++ )
  34. {
  35. Console.WriteLine(newsegment.Array[i]);
  36. }
  37. }
  38. }
  39. }
Success #stdin #stdout 0.03s 33696KB
stdin
Standard input is empty
stdout
-- Array --
15
25
35
-- Offset --
1
-- Count --
2
-- Range --
25
35