fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. double[] array = new double[] {1,2,3,4,5};
  8. var indexer1 = new Index(array, 1, 2);
  9. Console.WriteLine(indexer1[0]);
  10. }
  11.  
  12. class Index {
  13. private readonly double[] arr;
  14. private readonly int offset; // set this to x in the constructor
  15. public int Length { get { return arr.Length; } }
  16. public double this[int idx] {
  17. get { return arr[idx+offset]; }
  18. set { arr[idx+offset] = value; }
  19. }
  20. public Index(double[] arr1, int x, int y) {
  21. arr = arr1;
  22. offset = x;
  23. }
  24. }
  25.  
  26.  
  27.  
  28. }
Success #stdin #stdout 0.02s 14696KB
stdin
Standard input is empty
stdout
2