Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace newArray
  8. {
  9. class Program
  10. {
  11. static void Main()
  12. {
  13. rangeofarray arr = new rangeofarray(-5, 15);
  14. int j = 7;
  15. for (int i = -5; i < 15; i++)
  16. {
  17. arr[i] = j;
  18. j++;
  19. }
  20. Console.WriteLine(arr[-4]);
  21. }
  22.  
  23. }
  24. }
  25.  
  26.  
  27.  
  28.  
  29.  
  30. using System;
  31. using System.Collections.Generic;
  32. using System.Linq;
  33. using System.Text;
  34. using System.Threading.Tasks;
  35.  
  36. namespace newArray
  37. {
  38. class rangeofarray
  39. {
  40. private int minIndex;
  41. private int maxIndex;
  42. private int[] array;
  43. public rangeofarray(int minIndex, int maxIndex)
  44. {
  45. this.minIndex = minIndex;
  46. this.maxIndex = maxIndex;
  47. array = new int[maxIndex - minIndex + 1];
  48. }
  49.  
  50. public int this[int index]
  51. {
  52. get
  53. {
  54. return array[index - minIndex];
  55. }
  56. set
  57. {
  58. array[index - minIndex] = value;
  59. }
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement