Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApplication2
- {
- public class MyArray : IArray
- {
- public int Length { get; }
- public double[] arr = new double[10000];
- int nextIndex = 0;
- public object this[int i]
- {
- get => arr[i];
- set => arr[i] = (int)value;
- }
- public MyArray(int a)
- {
- this.Length = a;
- this.nextIndex = a;
- this.arr = new double [a];
- }
- public void Add(int value)
- {
- if (nextIndex >= arr.Length)
- throw new IndexOutOfRangeException($"Out of bounds");
- arr[nextIndex] = value;
- ++nextIndex;
- }
- }
- }
Add Comment
Please, Sign In to add comment