In a console application, where I have a string type arrangement, one of the operations allows inserting values in places that are occupied, for example:
I have an array in the following way: {cero, uno, 0, 0 ,0}
.
The zeros are null values, if you want to insert another value such as 'ncero' in the zero position, the current values must be traversed, being as follows:
{ncero, cero, uno, 0, 0}
The problem is when crossing it when they have more than one value occupied, if someone could help me.
if (respuesta == "2")
{
bool señal = false;
Console.Clear();
Console.WriteLine("En que posicion desea insertar el dato?");
respuesta = Console.ReadLine();//Lee el dato de manera String
i = int.Parse(respuesta);//Convierte la posicion en tipo Int
if (i > 9)//Si la posicion ingresada es mayor que el tamaño del array manda error
Console.WriteLine("Ingrese una posicion valida");
else
Console.WriteLine("Ingrese el valor que desea agregar");
respuesta = Console.ReadLine();//Lee el dato a ingresar
if (Nombres[i] != null)//Si en la posicion deseada hay ya un valor
{
for (int x = i + 1; x < Nombres.Length; x++)//Recorre todo el arreglo
{
}