ola. Eu estou a realizar um programa em C# console application.. e tenho k eliminar um cliente e passar esse cliente eliminado para um outro vector o codigo que fiz foi:
Código:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000][COLOR=white][] inactivos_part =[/COLOR] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=white][5]; // crio um novo vector para guardar os clientes eliminados[/COLOR]
[/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Console[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"introduza o codigo do cliente Particular"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]); [/SIZE][SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] elimina_part = [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Convert[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].ToInt32([/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Console[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].ReadLine()); // introduzo o codigo do cliente k quero eliminar[/SIZE]
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i = 0; i < ultimoCliente; i++)
{
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (elimina_part == tabela1[i].Cod_part) // verifico se o cliente existe no vector "tabela1"
{
[/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Console[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].WriteLine(tabela1[i].listagem());
}
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] j = 0; j < inactivos_part.Length; j++) // percorro o vector inactivos para verificar onde esta livre para colocar o cliente eliminado[/SIZE]
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (inactivos_part[j] == [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])
{
inactivos_part[j] = tabela1[i]; // [COLOR=yellow]depois digo que o novo vector vai conter o cliente eliminado mas nao funciona desta maneira... nesta linha dá erro[/COLOR]
}
}
[/SIZE]
Última edição pelo moderador: