I'm looking for a method to satisfy the need to insert a value in a index and if that index is busy all the next values of the array will slide down:
char[] myArray = new char[5];
myArray[0] = 'a';
myArray[1] = 'b';
myArray[2] = 'c';
myArray[3] = 'd';
myArray[4] = 'e';
char missingChar = 'k';
//I want to insert the char "missingChar" in myArray[2]
//I want all the other indexes to move down, the former-myArray[2] also
Array.Resize(ref myArray, myArray.Length + 1);
myArray[0] = 'a';
myArray[1] = 'b';
myArray[2] = missingChar;
myArray[3] = 'c';
myArray[4] = 'd';
myArray[5] = 'e';
The output desired is:
a, b, k, c, d, e
Is there a way to do this without involving lists?