Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace newArray
- {
- class Program
- {
- static void Main()
- {
- rangeofarray arr = new rangeofarray(-5, 15);
- int j = 7;
- for (int i = -5; i < 15; i++)
- {
- arr[i] = j;
- j++;
- }
- Console.WriteLine(arr[-4]);
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace newArray
- {
- class rangeofarray
- {
- private int minIndex;
- private int maxIndex;
- private int[] array;
- public rangeofarray(int minIndex, int maxIndex)
- {
- this.minIndex = minIndex;
- this.maxIndex = maxIndex;
- array = new int[maxIndex - minIndex + 1];
- }
- public int this[int index]
- {
- get
- {
- return array[index - minIndex];
- }
- set
- {
- array[index - minIndex] = value;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement