3
I have the following code:
Console.Clear();
Console.Write("Nome da moto:");
string nomem = Console.ReadLine();
for (int i = 0; i < ListadeVeiculos.Count; i++)
{
if (nomem == ListadeVeiculos[i].Nomemoto)
Console.Write("Preço R$:" +ListadeVeiculos[i].Preco.ToString("0.00"));
else Console.Write("Moto não cadastrada!");
}
Console.ReadKey();
Do you have a way to stop it when you find the element in the List?
In that my code if insert 2 elements in the list shows the message of if
and of else
.
Is that so? https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/break
– hkotsubo