csharp beginner

csharp beginner

  • NA
  • 38
  • 12k

inserting a value

Nov 10 2013 2:08 PM
I want to insert some values to an array. 

The array would not have any fixed size and would be containing some elements. Now, what i want to do is : insert certain elements(values), at certain index positions. But, the element which was already there at that index position would not be deleted, else would be shifted a position next. Thus, inserting a new element at the required position and also keeping all the elements without deleting any, at the mean while, the size of the array would also be increased (as obviously). 

Example:

int[] arr = { 22, 32, 45, 68, 92};

If i insert an element (say, 46) at 2nd position in the array, then, array should become

arr = {22, 46, 32, 45, 68, 92}

Can anybody help?

Regards

Answers (2)