My idea is to make a small registration and I'm testing this for later adding that data to a DB. The problem occurs at line Console.Write("\nGenero do disco : {1}", genero);
, at the time of displaying the string read via keyboard. Here is the error:
Exception without treatment System.FormatException: 'Index (zero-based) must be greater than or equal to zero and smaller than the argument list size.'
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Cadastro_de_músicas
{
class Disco
{
public string nome;
public string genero;
public string ano;
public void cadastra()
{
Console.Write("Digite o nome do disco: ");
nome = Console.ReadLine();
Console.Write("Digite o genero do disco: ");
genero = Console.ReadLine();
Console.Write("Digite o ano do disco: ");
ano = Console.ReadLine();
}
public void exibe()
{
Console.Write("Nome do disco: {0}", nome);
Console.Write("\nGenero do disco : {1}", genero);
Console.Write("\nAno do disco: {2}", ano);
Console.ReadKey();
}
}
}